fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Test {
  5. public:
  6. int a;
  7. Test () : a(0) {}
  8. };
  9.  
  10. class Lol {
  11. public:
  12. int a;
  13. Lol () : a(0) {}
  14. };
  15.  
  16. void fun (Test * test)
  17. {
  18. cout << "obiekt wew fun przed operatorem = " << test->a << endl;
  19. test->a = 3;
  20. cout << "obiekt wew fun po operatorze = " << test->a << endl;
  21. }
  22.  
  23. int main()
  24. {
  25. Lol obiekt;
  26. obiekt.a = 9;
  27. cout << "obiekt przed fun: " << obiekt.a << endl;
  28. fun((Test*)(void*)&obiekt);
  29. cout << "obiekt po fun: " << obiekt.a << endl;
  30. cin.get();
  31. return 0;
  32. }
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
obiekt przed fun: 9
obiekt wew fun przed operatorem = 9
obiekt wew fun po operatorze = 3
obiekt po fun: 3