Click here to Skip to main content
15,907,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Information about a file ? Pin
Hamid_RT16-May-08 3:07
Hamid_RT16-May-08 3:07 
AnswerRe: Information about a file ? Pin
CPallini16-May-08 3:11
mveCPallini16-May-08 3:11 
AnswerRe: Information about a file ? Pin
David Crow16-May-08 4:56
David Crow16-May-08 4:56 
QuestionVisual C++ 5.0 and NorthwindOledb sample error Pin
waquasalig16-May-08 2:30
waquasalig16-May-08 2:30 
QuestionError occur "Overlapped i/o operations in progress" Pin
ShilpiP16-May-08 2:15
ShilpiP16-May-08 2:15 
Questionproblem in loading grid control Pin
waquasalig16-May-08 2:08
waquasalig16-May-08 2:08 
Question[Message Deleted] Pin
Kwanalouie16-May-08 1:28
Kwanalouie16-May-08 1:28 
AnswerRe: Help with global class variables in multiple files Pin
Nelek16-May-08 1:41
protectorNelek16-May-08 1:41 
Mmmm, is the word extern what you are looking for?

Globals.cpp
int globalInt = 0;
CString globalStr = "";
CMyDoc* myDoc = NULL;


other1.cpp
extern int globalInt;
globalInt = 3;


other2.cpp
extern int globalInt;
if (globalInt == 3)
   AfxMessageBox ("GloballyModified");
else
   AfxMessageBox ("not working");


Of course, other1.cpp should be executed before than other2.cpp

ADD:
I would use the Global.h to declare constants, all the includes that are going to be needed in all other modules, and things like that, but for variables I prefer it like above

Greetings.
--------
M.D.V. Wink | ;)

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

GeneralRe: Help with global class variables in multiple files Pin
Kwanalouie16-May-08 1:48
Kwanalouie16-May-08 1:48 
GeneralThe question was... Pin
Nelek16-May-08 1:58
protectorNelek16-May-08 1:58 
AnswerRe: [Message Deleted] Pin
Michael Schubert16-May-08 1:47
Michael Schubert16-May-08 1:47 
RantRe: [Message Deleted] [modified] Pin
toxcct16-May-08 1:53
toxcct16-May-08 1:53 
QuestionRe: [Message Deleted] Pin
CPallini16-May-08 1:55
mveCPallini16-May-08 1:55 
GeneralRe: [Message Deleted] Pin
Michael Schubert16-May-08 2:15
Michael Schubert16-May-08 2:15 
GeneralRe: [Message Deleted] Pin
toxcct16-May-08 2:17
toxcct16-May-08 2:17 
AnswerRe: [Message Deleted] Pin
Hamid_RT16-May-08 2:06
Hamid_RT16-May-08 2:06 
GeneralRe: [Message Deleted] Pin
ThatsAlok6-Jul-09 20:16
ThatsAlok6-Jul-09 20:16 
GeneralRe: [Message Deleted] Pin
Hamid_RT7-Jul-09 1:08
Hamid_RT7-Jul-09 1:08 
QuestionHow to read Japanese from String Table? Pin
sumit.durg16-May-08 1:24
sumit.durg16-May-08 1:24 
AnswerRe: How to read Japanese from String Table? Pin
Michael Schubert16-May-08 1:28
Michael Schubert16-May-08 1:28 
GeneralRe: How to read Japanese from String Table? Pin
sumit.durg16-May-08 3:13
sumit.durg16-May-08 3:13 
AnswerRe: How to read Japanese from String Table? Pin
Hamid_RT16-May-08 1:30
Hamid_RT16-May-08 1:30 
QuestionRe: How to read Japanese from String Table? Pin
Rajesh R Subramanian16-May-08 1:33
professionalRajesh R Subramanian16-May-08 1:33 
AnswerRe: How to read Japanese from String Table? Pin
Hamid_RT16-May-08 1:41
Hamid_RT16-May-08 1:41 
GeneralRe: How to read Japanese from String Table? Pin
sumit.durg16-May-08 3:15
sumit.durg16-May-08 3:15 

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.