Click here to Skip to main content
15,905,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: access variable from another file Pin
ptr_Electron28-Mar-08 3:54
ptr_Electron28-Mar-08 3:54 
QuestionRe: access variable from another file Pin
CPallini28-Mar-08 4:02
mveCPallini28-Mar-08 4:02 
GeneralRe: access variable from another file Pin
ptr_Electron28-Mar-08 4:08
ptr_Electron28-Mar-08 4:08 
GeneralRe: access variable from another file [modified] Pin
CPallini28-Mar-08 4:21
mveCPallini28-Mar-08 4:21 
GeneralRe: access variable from another file Pin
ptr_Electron28-Mar-08 5:38
ptr_Electron28-Mar-08 5:38 
QuestionRe: access variable from another file Pin
CPallini28-Mar-08 5:45
mveCPallini28-Mar-08 5:45 
GeneralRe: access variable from another file Pin
ptr_Electron28-Mar-08 6:12
ptr_Electron28-Mar-08 6:12 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 6:22
mveCPallini28-Mar-08 6:22 
Don't make it static.
Other people suggested to make it static member of a class, not to do a static variable declaration. Static variable declaration make the variable itself having file-scope, i.e. it is visible only inside the file wherein it was declared.
I repeat, if you want to use a global variable:
(1) declare it inside you header file as extern int.
(2) declare it inside one source file as int.
(3) include the header file inside all source files.
Hope that helps.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke


GeneralRe: access variable from another file Pin
ptr_Electron1-Apr-08 22:42
ptr_Electron1-Apr-08 22:42 
GeneralRe: access variable from another file Pin
CPallini1-Apr-08 23:04
mveCPallini1-Apr-08 23:04 
GeneralRe: access variable from another file Pin
Nemanja Trifunovic28-Mar-08 4:15
Nemanja Trifunovic28-Mar-08 4:15 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 4:23
mveCPallini28-Mar-08 4:23 
GeneralRe: access variable from another file Pin
Matthew Faithfull28-Mar-08 4:50
Matthew Faithfull28-Mar-08 4:50 
GeneralRe: access variable from another file Pin
Nemanja Trifunovic28-Mar-08 5:03
Nemanja Trifunovic28-Mar-08 5:03 
GeneralRe: access variable from another file Pin
Matthew Faithfull28-Mar-08 5:20
Matthew Faithfull28-Mar-08 5:20 
GeneralRe: access variable from another file Pin
Nemanja Trifunovic28-Mar-08 7:18
Nemanja Trifunovic28-Mar-08 7:18 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 5:21
mveCPallini28-Mar-08 5:21 
GeneralRe: access variable from another file Pin
Nemanja Trifunovic28-Mar-08 7:19
Nemanja Trifunovic28-Mar-08 7:19 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 5:03
mveCPallini28-Mar-08 5:03 
JokeRe: access variable from another file Pin
Matthew Faithfull28-Mar-08 5:21
Matthew Faithfull28-Mar-08 5:21 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 5:42
mveCPallini28-Mar-08 5:42 
GeneralRe: access variable from another file Pin
toxcct28-Mar-08 5:43
toxcct28-Mar-08 5:43 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 5:48
mveCPallini28-Mar-08 5:48 
GeneralRe: access variable from another file Pin
toxcct28-Mar-08 5:54
toxcct28-Mar-08 5:54 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 5:59
mveCPallini28-Mar-08 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.