October 2011
Beginner to intermediate
1200 pages
35h 33m
English
It’s possible to declare a member function as being static. (The keyword static should appear in the function declaration but not in the function definition if the latter is separate.) This has two important consequences.
First, a static member function doesn’t have to be invoked by an object; in fact, it doesn’t even get a this pointer to play with. If the static member function is declared in the public section, it can be invoked using the class name and the scope-resolution operator. For instance, you can give the String class a static member function called HowMany() with the following prototype/definition in the class declaration:
static int HowMany() { return num_strings; }
It could be invoked like this:
Read now
Unlock full access