Guest User

Untitled

a guest
May 28th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  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;
Advertisement
Add Comment
Please, Sign In to add comment