-
static function
What is the role of a static member function ?
In case I don't know about static stuff, will declaring and using an ordinary member function offer the same result ?
class CLASS
{
public :
static void func();
};
and
class CLASS
{
public :
void func();
};
Would you mind show me significant differences between the use of both in terms of
1. linking,
2. storing,
3. compiling
4. functioning
Thank you
-
Re: static function
To put it short, the major advantage of a static member function is that you don't need an instance of your class (i.e. a concrete object) to call it on. However, this also brings along the major disadavantage: As you don't have an associated object you can't (directly) access any non-static class members from a static member function.
-
Re: static function
A static method is basically a function which is closely associated with the class (possibly even private to it), but which does not directly manipulate an object of the class type.