C++ Language/Objects/StaticMembers/StaticMemberFunctions

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Most member functions conceptually manipulate one specific object, but a member function marked by the static keyword is for computation that is collectively about all objects of that class. The compiler doesn't provide any this pointer to a static-member-function, so a static-member-function can only access static-data-members. Whereas an ordinary member function is invoked on a specific object (oObject.DoAction()), any code may invoke a static-member-function without having any object (simply calling CRType::DoAction()).

Additional information about static-member-functions