what is the extern keyword for.
Printable View
what is the extern keyword for.
extern allows you to use global variables defined in one file( remember they have file scope) in another file. For example:
Code://file 1
int Cats = 5
void printcats(){
cout<<Cats;
}
//file 2
extern int Cats //declare variable in current file
void ShowCats(){
cout<<Cats;
}