fork download
  1. #include <iostream>
  2. using namespace std;
  3. class A {
  4. private:
  5. int numberOfElements;
  6.  
  7. public:
  8. A() : numberOfElements(0) {}
  9. void add() { numberOfElements++;
  10. std::cout << numberOfElements << std::endl;
  11. }
  12. };
  13. int main() {
  14. A a;
  15. a.add();
  16. a.add();
  17.  
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1
2