problem with globals
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?
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:
in your source (.cpp) file and declare it extern like so:
in the header file.
[edit]Damn, I'm always too late [headshake][/edit]
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
Popular Topics
Advertisement