I am a newbie so please be easy on me
I have C file...which has following for an example.
Now I have a C++ file.....Code:extern int globalvar; void init() { While (something) { x++ } globalvar = x; } int getglobalvar (void) { return(globalvar); }
Which I have a function
basically I will be then calling this function needGlobalvar in another C++ else....whats the best way I could move the functionCode:void needGlobalvar() { int y = getglobalvar() }
to C++ and still have the access to correct information set in the C function for the globalvarCode:int getglobalvar (void) { return(globalvar); }
One of my friends said to make the globalvar a singleton and access it so this way it will be safe....could someone please help me with how I could use the sigleton...because I have not done that before.....



LinkBack URL
About LinkBacks



