Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- #include <vector> ;
- using namespace std;
- class Q
- {
- public:
- int x;
- Q();
- Q(const Q& q);
- Q& operator=(const Q& q);
- };
- Q::Q(): x(0)
- {
- cout << "1";
- }
- Q::Q(const Q& q)
- {
- cout << "2";
- x = q.x;
- }
- Q& Q::operator=(const Q &q)
- {
- cout <<"3";
- x = q.x;
- return *this;}
- void foo(Q q4, Q& q5)
- {
- Q q6 = q4;
- q6 = q5;
- }
- void bar()
- {
- Q q1;
- Q q2 = q1;
- q1 = q2;
- Q q3(q1);
- foo(q1, q2);
- }
- int main(){
- bar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement