fork download
  1. #include <iostream>
  2.  
  3. class StaticExample {
  4. public:
  5. static int n_constructions;
  6.  
  7. StaticExample() {
  8. n_constructions++;
  9. std::cout << "construction number " << n_constructions << std::endl;
  10. }
  11. };
  12.  
  13. int StaticExample::n_constructions = 0;
  14.  
  15. int main() {
  16. for (int i = 0; i < 5; i++) {
  17. StaticExample se;
  18. }
  19. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
construction number 1
construction number 2
construction number 3
construction number 4
construction number 5