-
May 19th, 2011, 01:39 PM
#1
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
-
May 19th, 2011, 01:49 PM
#2
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.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
May 19th, 2011, 02:02 PM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|