fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Contador {
  5. public:
  6. Contador(int c = 0) { contador = c; };
  7. int getContador() { return contador; };
  8. Contador& operator++() {
  9. ++contador;
  10. return *this;
  11. };
  12. private:
  13. unsigned int contador;
  14. };
  15.  
  16. int main() {
  17. Contador c1, c2, c3;
  18. ++c1;
  19. ++c2;
  20. ++c2;
  21. ++c2;
  22. c3 = ++c2;
  23. ++(++(++c1));
  24. cout << "c1: " << c1.getContador() << endl;
  25. cout << "c2: " << c2.getContador() << endl;
  26. cout << "c3: " << c3.getContador() << endl;
  27. }
  28.  
  29. //https://pt.stackoverflow.com/q/174895/101
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
c1: 4
c2: 4
c3: 4