Defining static members

When you use static on a class member it means that the item is associated with the class and not with a specific instance. In the case, of data members, this means that there is one data item shared by all instances of the class. Likewise, a static method is not attached to an object, it is not __thiscall and has no this pointer.

A static method is part of the namespace of a class, so it can create objects for the class and have access to their private members. A static method has the __cdecl calling convention by default, but you can declare it as __stdcall if you wish. This means that, you can write a method within the class that can be used to initialize C-like pointers, which are used by many libraries. Note that ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.