fork(1) download
  1. #include <iostream>
  2.  
  3. class Test{
  4. private:
  5. int a;
  6. public:
  7. Test(int i, int j) : a{i}, b{j} {}
  8. void show();
  9. int b;
  10. };
  11.  
  12. void Test::show(){
  13. std::cout << a << " " << b << std::endl;
  14. }
  15.  
  16. void doMagic(Test& x){
  17. Test* objPtr = &x;
  18. int* tabPtr = reinterpret_cast<int*>(objPtr);
  19. tabPtr[0] = 41;
  20. tabPtr[1] = 1313;
  21. }
  22.  
  23. int main(){
  24. Test x(1, 2);
  25. std::cout << "Przed modyfikacja: ";
  26. x.show();
  27. doMagic(x);
  28. std::cout << "Po modyfikacji: ";
  29. x.show();
  30. return 0;
  31. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Przed modyfikacja: 1 2
Po modyfikacji: 41 1313