That's not what you think. That's a static member function. When you
declare a member function static, you will have access to the function
outside of the class, without instantiating an instance of the class. One
thing about this is that the function will not have access to any of the
none static members of the class. The Static member function is a very good
method for singleton classes. Try reading Effective C++, More Effective
C++, and Design Patterns.
Ali R.
class A
{
public:
static int DoSomething();
private:
int m_Counter;
static int m_StaticCounter;
}
int A::DoSomething()
{
m_StaticCounter++; //this is fine
m_Counter++; //error!!!
}
main()
{
A::DoSomething(); //this is also fine.
}
"Roman Simkin" <fa*****@inbox.lv> wrote in message
news:3f******@news.bezeqint.net...
Hi,
As far as I know, a static variable is a variable that belongs to a
function or a class (are there any other options?). I've seen somewhere a function
that *returns* static types - something like:
static [const] someType myFunction() {...}
What is the meaning of it?? Or did I get something wrong?
Thanks!
Roman.