fork(3) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Foo {
  6.  
  7. public:
  8.  
  9. Foo()
  10. {
  11. counter++;
  12. }
  13.  
  14. static int getCount()
  15. {
  16. return counter;
  17.  
  18. }
  19. protected:
  20. static int counter;
  21. };
  22.  
  23. int Foo::counter = 0;
  24. int main(int argc, char *argv[]) {
  25.  
  26. Foo f;
  27. Foo b;
  28. cout << Foo::getCount() << endl;
  29. }
  30.  
Success #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
2