![]() |
#2
wufuzhang2019-08-11 20:02
|

#ifndef _TEST_H
#define _TEST_H
extern int a;
#endif
test1.cpp

#include <iostream>
#include "test1.h"
int a = 1;
test.cpp

#include "test1.h"
#include <iostream>
using namespace::std;
a = 2; // 如果这样写会出错, does not name a type 将这行放在 main 中赋值就没有问题,这是为什么
int main() {
cout << a << endl;
}