Aug 19, 2001 #1 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.
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.
Aug 19, 2001 #2 jtm111 Programmer Jun 27, 2001 103 US 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... *********************** Upvote 0 Downvote
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... ***********************