Click here to Skip to main content
16,012,173 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How could be visual studio 2008 so slow and need so much memory? Pin
followait28-Mar-08 23:27
followait28-Mar-08 23:27 
GeneralRe: How could be visual studio 2008 so slow and need so much memory? Pin
led mike31-Mar-08 5:41
led mike31-Mar-08 5:41 
GeneralDICOM IMAGES - WHAT IS ALPHA Pin
paul crescent28-Mar-08 4:09
paul crescent28-Mar-08 4:09 
GeneralRe: DICOM IMAGES - WHAT IS ALPHA Pin
led mike28-Mar-08 4:30
led mike28-Mar-08 4:30 
GeneralRe: DICOM IMAGES - WHAT IS ALPHA Pin
Dave Kreskowiak28-Mar-08 8:10
mveDave Kreskowiak28-Mar-08 8:10 
Generalaccess variable from another file Pin
ptr_Electron28-Mar-08 2:32
ptr_Electron28-Mar-08 2:32 
GeneralRe: access variable from another file Pin
toxcct28-Mar-08 3:01
toxcct28-Mar-08 3:01 
GeneralRe: access variable from another file Pin
CPallini28-Mar-08 3:12
mveCPallini28-Mar-08 3:12 
If you wish to use a global variable the correct way is.
1. Define it in one of your source (*.cpp) files.
2. Declare it as extern in the other source files.

for instance:

file foo1.cpp
int iGlobal;

file foo2.cpp, foo3.cpp, foo4.cpp, ...
(alternatively you may include the following declaration inside a header file, included by all the above sources)
extern int iGlobal;


IMHO global varibles are not evil, anyway you should use it sparingly. OOP offers some techniques to avoid typical global variables issues (like name clashes, arbitray access...).
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_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 
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 

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.