fork download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3. class C
  4. {
  5. public:
  6. C()
  7. {
  8. cout<<++c<<endl;
  9. }
  10. static int Getc()
  11. { return c;}
  12. ~C()
  13. {
  14. cout<<c--<<endl;
  15. }
  16. private:
  17. static int c;
  18. };
  19. int C::c=0;
  20. int main()
  21. {
  22. C c1,c2,c3,c4,c5;
  23. cout<<C::Getc()<<endl;
  24. }
Success #stdin #stdout 0s 5284KB
stdin
1H4G9U8E2Y
stdout
1
2
3
4
5
5
5
4
3
2
1