Board index » cppbuilder » Thanks Gambit

Thanks Gambit


2006-07-20 07:58:04 AM
cppbuilder20
Gambit
Your suggestion helped me to the solution
I removed the declaration of instance *ufo from graph1.cpp and
placed it in graph1.h
and
removed the include file graph1.cpp from Unit5.cpp and replaced
it with graph1.h.
The #includes now read
C:\. . . \graph1.cpp(13): #include "graph1.h"
C:\. . . \graph1.cpp(14): #include "Unit2.h"
C:\. . . \graph1.cpp(15): #include "Unit3.h"
C:\. . . \graph1.cpp(16): #include "Unit4.h"
C:\. . . \graph1.cpp(17): #include "Unit5.h"
C:\. . . \Unit2.cpp(5): #include "Unit2.h"
C:\. . . \Unit3.cpp(5): #include "Unit3.h"
C:\. . . \Unit1.cpp(5): #include "Unit1.h"
C:\. . . \Unit4.cpp(5): #include "Unit4.h"
C:\. . . \Unit5.cpp(16): #include "Unit5.h"
C:\. . . \Unit5.cpp(17): #include "graph1.h"
instance *ufo will now pass by reference in Unit5.cpp :-))
I don't understand what I have done but thanks
johnp
 
 

Re:Thanks Gambit

"johnp" < XXXX@XXXXX.COM >wrote in message
Quote
I removed the declaration of instance *ufo from
graph1.cpp and placed it in graph1.h
You have to be careful with that. If the actual variable is declared in
graph.h, then each unit that includes graph.h will get its own copy of that
variable, and thus you will be right back where you started this discussion.
If you want the variable to be global, then you need to declare it in a .cpp
file, and then use 'extern' in the variable's declaration in the .h file,
like I showed you earlier.
Gambit
 

Re:Thanks Gambit

Hi Gambit,
I was beating my head trying to get some thread issue working,
and getting the CoInitialize error. I was trying to put together
an example to post, when I checked the Tamarack Associates archive
and came across your response to someone else with a similar enough
problem.
Followed your example and my problem is solved.
Just wanted to say thanks,
Kerry
 

{smallsort}