programming - 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 - Class Static data and functions
programming - C - function ispunct
programming - sqlite2 - c interface
programming - sqlite3 - c interface - sqlite3_exec()
programming - windows - CreateWindowEx
programming - sqlite3 - c interface
programming - windows - windows message decoding
programming - HTML - listboxes
programming - sqlite3 - c interface - sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*)
programming - windows - CreateWindow
programming - C - function isupper
programming - sqlite2
programing tkinter Toplevel
electronics - etching PC boards
health - DNA
health - triglyceride
etching with UV film resist
health - weight loss
filename:programming - cpp - Class Static data and functions
filename:programming%20%2D%20cpp%20%2D%20Class%20Static%20data%20and%20functions
last edit:April 09 2009 23:03:08 (6332 days ago)
ct = 1786425754.000000 = August 11 2026 01:22:34
ft = 1239332588.000000 = April 09 2009 23:03:08
dt = 547093166.000000