I am not sure if the extern command is specifically C++ or C, but I know it work with C++. I see it used a lot in the q3 coding and wondered what it did. Thanks for the help.
Printable View
I am not sure if the extern command is specifically C++ or C, but I know it work with C++. I see it used a lot in the q3 coding and wondered what it did. Thanks for the help.
extern specifies that the variable is in another file.
first it works with C and C++.
now as how to use it heres how
say you have a variable(int k = 10) in mycpp1.cpp and you want to use it in mycpp2.cpp use the extern to redeclare the variable and use it.
Example:
Code://mycpp1.cpp
int k = 10;
this will printCode://mycpp2.cpp
extern int k;
void function(void)
{
cout << k << endl;
}
10
Thanks! That solved the only problem I had with my app.