fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Test
  5. {
  6. public:
  7. Test() : x(10) {}
  8. int getTest() { return x; }
  9. private:
  10. int x;
  11. };
  12.  
  13. class Change
  14. {
  15. public:
  16. int x;
  17. };
  18.  
  19. int main() {
  20. Test test; // x is 10
  21. void* dirty = &test;
  22. Change* modify = (Change*)dirty;
  23. modify->x = 15;
  24. cout << test.getTest();
  25. return 0;
  26. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
15