Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quesiton about globals

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
i have 2 seperate classes....where would i define a global variable so that both classes can access it?
 
In another header file define an extern variable like this:

<MyVariableType> <MyVariable>

and in your files include:

extern <MyVariableType> <MyVariable>

A variable declared with the extern storage-class specifier is a reference to a variable with the same name defined at the external level in any of the source files of the program. The internal extern declaration is used to make the external-level variable definition visible within the block. Unless otherwise declared at the external level, a variable declared with the extern keyword is visible only in the block in which it is declared.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top