problem with globals

Started by
1 comment, last by demonkoryu 18 years, 8 months ago
I have a variable declared in a header file apps.h: static boost::shared_ptr<aClass> varname; I want it to be visibale through all the project files so I have it static. BUT this is causing problems with my stack. Is there ANY other way I can make this global without it being static?
Gary.Goodbye, and thanks for all the fish.
Advertisement
See if making it extern and then declaring it in a .cpp file somewhere helps.

Read about it here.
....[size="1"]Brent Gunning
When you make a variable static in global scope, you effectively restrict it from beeing visible outside the file you declared it in. So, the solution to your problem is to define the variable like so:
boost::shared_ptr<aClass> varname;

in your source (.cpp) file and declare it extern like so:
extern boost::shared_ptr<aClass> varname;

in the header file.

[edit]Damn, I'm always too late [headshake][/edit]

This topic is closed to new replies.

Advertisement