On Nov 13, 5:31 pm, Han <Mingwei....@gmail.comwrote:
If I define a variable in a.cpp as a global variable,but I want to use
it in b.cpp. How to do that?
For example
//a.cpp
vector<int* p
void main()
{
}
//b.cpp How can I use "p" here?
......
Use "extern" to declare this variable before you use it. For example
in b.cpp, you can write this:
extern vector<int*p;
//use p...
Generally, an extern declaration is put in a header file, so that it
can be easily used by other files.