Advertisement
zielo

4RL

Apr 10th, 2018
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class complex_base
  5. {
  6.     double a, b;
  7. public:
  8.     complex_base()
  9.     {
  10.         a=0;
  11.         b=0;
  12.     }
  13.     complex_base(double a1, double b1)
  14.     {
  15.         a=a1;
  16.         b=b1;
  17.     }
  18.     double real()
  19.     {
  20.         return a;
  21.     }
  22.     void real(double a)
  23.     {
  24.         this->a = a;
  25.     }
  26.     double imag()
  27.     {
  28.         return b;
  29.     }
  30.     void imag(double b)
  31.     {
  32.         this->b = b;
  33.     }
  34.     void print()
  35.     {
  36.         cout << a << ", j" << b;
  37.     }
  38.  
  39. };
  40.  
  41. int main()
  42. {
  43.     complex_base X(7, -10);
  44.     complex_base& Y = X;
  45.     cout << "Wyswietlam X: ";
  46.     X.print();
  47.     cout << "\nWyswietlam Y: ";
  48.     Y.print();
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement