Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// copy constructor
- #include<bits/stdc++.h>
- using namespace std;
- class code
- {
- int x;
- public:
- code(int c)
- {
- x=c;
- }
- code(code &a,int m)
- {
- x = m;
- a.x = x;
- }
- int get()
- {
- return x;
- }
- void set(int a)
- {
- x = a;
- }
- };
- int main()
- {
- code a(500),b(a,888),c =a;
- cout<<b.get()<<endl;
- cout<<a.get()<<endl;
- cout<<c.get()<<endl;
- c.set(50);
- a.set(69);
- cout<<a.get()<<" "<<c.get()<<" " <<b.get()<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment