ID:276658
 
Any one know what static member variables scope is?
class bar{
public:
static int foo;
};
func(){
int bar::foo = 10;
}

So I guess what I am asking is. Will that static vairable in the ... Well does it go in the stack or in global space? Any way does it end when the function ends?

+

Can you have static member vairables on the free store(heap)? If so how?

Thanks for any help you byonders provide. I await your answers with great aniticipation.

*Pardon my spelling errors*
Stack or heap? Not sure, to be perfectly honest, and it probably doesn't matter anyway. You would treat it as if it's a stack variable, though. (i.e. You don't have to explicitly delete it.)

Will it go away when the function ends? No. It will stick around until the program exits.