fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class X {
  5. public:
  6. int v;
  7. void put(int x) { v = x; }
  8. int get(void) { return v; }
  9. };
  10.  
  11. class Y : public X {
  12. public:
  13. Y() { put(0); }
  14. void write(int x) { put(x + 1); }
  15. int read(void) { return get() - 1; }
  16.  
  17. };
  18.  
  19. int main() {
  20. Y *y = new Y();
  21. y->write(1);
  22. cout << y->read();
  23. delete y;
  24. return 0;
  25. }
  26.  
  27.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1