fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class GfG {
  5. int i;
  6.  
  7. public:
  8. GfG()
  9. {
  10. i = 0;
  11. cout << "Inside Constructor\n";
  12. }
  13. ~GfG() { cout << "Inside Destructor\n"; }
  14. };
  15.  
  16. int main()
  17. {
  18. int x = 0;
  19. if (x == 0) {
  20. static GfG obj;
  21. }
  22. cout << "End of main\n";
  23. }
  24.  
Success #stdin #stdout 0.01s 5360KB
stdin
Standard input is empty
stdout
Inside Constructor
End of main
Inside Destructor