Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class A
- {
- public:
- int x, y;
- public:
- A(){x=1; y=2;}
- ~A(){cout<<x<<y;}
- friend ostream& operator<<(ostream &out, const A& a)
- {
- out<<a.x<<a.y;
- return out;
- }
- };
- void fun2(A a){a.x=2; a.y=2;}
- void fun1(A& a){a.x=1; a.y=1;}
- int main()
- {
- A a;
- fun1(a);
- cout<<a;
- fun2(a);
- return 0;
- }
- ispis je 112211
- 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