programming:cpp:Cpp Class Static data and functionsWhat links here?
A static member of a class is created once, when the program starts. There is only one static member, but each instance of the class can access it as if it were part of that particular instance.

A static data member can be initialized in a source file like a regular global variable:

int Test::public_int = 3;


class Test {
public:
    static int public_int;
private:
    static int private_int;
}


int main() { Test::public_int = 145; // ok Test::private_int = 12; // wrong, don't touch // the private parts return (0); }


A static function can only access the static data of the member. A public static function can be called without specifying an existing object:
Test::static_method(data)
or with an object:

    Test    foo;
    foo.static_method(data)


A C++ static member is like a Programming Ruby:Ruby Programming Ruby:Ruby Data Storage.
programming:cpp:Cpp Class Static data and functions
X Windows Structures - XMotionEvent
programming - c - structs - _finddata_t
programming - C - function strdup
programming - windows - WM_CREATE
programming:c:function isdigit
programming:c:function fseek
programming:c:function isalnum
programming:c:function strpbrk
programming:c:function strncat
programming:c:function strchr
programming:c:functions:_splitpath
programming:windows:SetWindowText
programming:c:function iscntrl
programming:cpp:Cpp operator overloading
programming:c:function rewind
programming:c:function strpos
programming:c:function strtok
filename:programming:cpp:Cpp Class Static data and functions
filename:programming%3Acpp%3ACpp%20Class%20Static%20data%20and%20functions
last edit:April 10 2009 03:03:08 (6425 days ago)
ct = 1794509847.000000 = November 12 2026 18:57:27
ft = 1239332588.000000 = April 10 2009 03:03:08
dt = 555177259.000000