csetanzil

Untitled

Nov 10th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. /// copy constructor
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. class code
  5. {
  6.     int x;
  7. public:
  8.     code(int c)
  9.     {
  10.         x=c;
  11.     }
  12.     code(code &a,int m)
  13.     {
  14.         x = m;
  15.         a.x = x;
  16.     }
  17.     int get()
  18.     {
  19.         return x;
  20.     }
  21.     void set(int a)
  22.     {
  23.         x = a;
  24.     }
  25. };
  26. int main()
  27. {
  28.     code a(500),b(a,888),c =a;
  29.     cout<<b.get()<<endl;
  30.     cout<<a.get()<<endl;
  31.     cout<<c.get()<<endl;
  32.     c.set(50);
  33.     a.set(69);
  34.     cout<<a.get()<<" "<<c.get()<<" " <<b.get()<<endl;
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment