Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class A
  4. {
  5. public:
  6. int x, y;
  7. public:
  8. A(){x=1; y=2;}
  9. ~A(){cout<<x<<y;}
  10. friend ostream& operator<<(ostream &out, const A& a)
  11. {
  12. out<<a.x<<a.y;
  13. return out;
  14. }
  15. };
  16.  
  17. void fun2(A a){a.x=2; a.y=2;}
  18. void fun1(A& a){a.x=1; a.y=1;}
  19.  
  20. int main()
  21. {
  22. A a;
  23. fun1(a);
  24. cout<<a;
  25. fun2(a);
  26. return 0;
  27. }
  28.  
  29. ispis je 112211
  30. Odakle 2211? I šta se dešava sa ovim parametrima po vrednosti i po referenci?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement