Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 28th, 2012  |  syntax: None  |  size: 0.58 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Static initialization of object
  2. class A { ... };
  3.  
  4. A obj1;
  5.  
  6. int main()
  7. {
  8.     static A obj2;
  9. }
  10.        
  11. // at namespace level
  12. int f();
  13. int a;         // 1 static: zero initialization
  14. int b = 10;    // 2 static: initialization from constant expression
  15. int c = f();   // 3 static (zero initialization)
  16.                // 5 followed by dynamic (result of call to f())
  17. int d = 20;    // 4 static: initialization
  18. int f() { return d; }
  19. int main() {}
  20.        
  21. class A {
  22.   // declaration of i as a static member of class A
  23.   static int i;
  24. };
  25.  
  26. // initialization of static member outside class A
  27. int A::i = 42;