Thomas Maeder wrote in a message to Neil Heller:
NH> TM> The keyword "static" is used for two purposes in C++.
NH> TM> 1. in class declarations to declare class methods/attributes.
NH> TM> 2. in implementation files to prevent the name of a function/
NH> TM> variable/constant from polluting the global namespace.
NH> I think maybe there are three, as can be seen by the replies I've
NH> already gotten.
TM> No, these are the two possibilities. It's just the
TM> wording that is different.
How about
int Counter()
{
static int i = 0;
return i++;
}
This does not limit the scope of i, but changes its lifetime.
In other words
3. to change the life time of a local variable in a function.
mvg/wr
--- timEd/2 1.01.g3+
---------------
* Origin: LightHouse BBS ==> I am a H.U.G.O. Member ! (2:285/324.3)
|