Advertisement
zielo

Untitled

Apr 10th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. class complex_base
  6. {
  7.   float re, im;
  8. public:
  9.   float real()
  10.   {
  11.     return re;
  12.   }
  13.   void real(float rr)
  14.   {
  15.     re=rr;
  16.   }
  17.   float img()
  18.   {
  19.     return im;
  20.   }
  21.   void img(float ii)
  22.   {
  23.     im=ii;
  24.   }
  25.   void print() const
  26.   {
  27.     cout << re << ",j" << im;
  28.   }
  29. };
  30. int main()
  31. {
  32.   shared_ptr<complex_base> x(new complex_base);
  33.   x->real(143);
  34.   x->img(-24);
  35.   shared_ptr<complex_base> y(new complex_base);
  36.   y=x;
  37.   y->print();
  38.   return 1;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement