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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global variabl

Status
Not open for further replies.

speedo

Programmer
Aug 24, 2001
13
DE
hello

Im using visual c++ 6.0 and I want to know how to declare a variable (int) which i want to use in all my source code.
 
Declare the variable as extern in your header file. Then declare the variable in just one source file (any one will do).


***********************
file.h

extern int iVariable;
***********************


***********************
file1.cpp

int iVariable;
***********************


***********************
file2.cpp, file3.cpp, etc.

not required to declare iVariable...
***********************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top