Friday, September 03, 2010

Static Variables

http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/cplr038.htm

 class C {       static int i;       static int j;       static int k;       static int l;       static int m;       static int n;       static int p;       static int q;       static int r;       static int s;       static int f() { return 0; }       int a; public:       C() { a = 0; }       };

 C c; int C::i = C::f();    // initialize with static member function int C::j = C::i;      // initialize with another static data member int C::k = c.f();     // initialize with member function from an object int C::l = c.j;       // initialize with data member from an object int C::s = c.a;       // initialize with nonstatic data member int C::r = 1;         // initialize with a constant value

 class Y : private C {} y;  int C::m = Y::f(); int C::n = Y::r; int C::p = y.r;       // error int C::q = y.f();     // error

No comments: