#include <iostream> using namespace std; class MyClass { static int a; int b; public: void set(int i, int j){ a=i; b=j; } static void show(); }; int MyClass::a; void MyClass::show(){ cout << "This is static a: " << a << endl; } int main(void) { MyClass x, y; x.set(1,1); y.set(2,2); MyClass::show(); y.show(); x.show(); }
9.26.static member functions | ||||
9.26.1. | A static member functions | |||
9.26.2. | Static method and static variable | |||
9.26.3. | name conflicts |