Re: [Dev-C++] Static in member function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <gen...@ya...> - 2003-09-20 02:51:55
|
Hello,
just in case no person has answered this (though i believe someone has), the answer is each object will have its own instance of the variable. in this case, the variable is simply a regular static variable in a function, and all the normal rules for static variable declared in a function apply.
cheers
NP
Bjorn Terelius <bjo...@ho...> wrote:
If a static variable is declared inside a member function of a class, what
would happen?
That is, would all instances of the class use the same value, or would each
instance have its own copy of the variable?
The function is defined something like this:
int Array::unshift() // unshift
{
static int *active=first;
// the function is supposed to return the i:th element on the i:th call
}
Thanks for any help
Bjorn Terelius
---------------------------------
Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger |