SHARE
TWEET

cplus

Dprogrammed1 Apr 1st, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.     using namespace std;
  3.     class Complex
  4.     {
  5.         private:
  6.         float real;
  7.         float imag;
  8.         public:
  9.         Complex():real(0), imag(0){}
  10.         Complex operator ()(float re, float im)
  11.         {
  12.             real += re;
  13.             imag += im;
  14.             return *this;
  15.         }
  16.         Complex operator() (float re)
  17.         {
  18.             real += re;
  19.             return *this;
  20.         }
  21.         void display()
  22.         {
  23.             cout << "(" << real << "," << imag << ")" << endl;
  24.         }
  25.     };
  26.     int main()
  27.     {
  28.         Complex c1, c2;
  29.         c2 = c1(3.2, 5.3);
  30.         c1(6.5, 2.7);
  31.         c2(1.9);
  32.         cout << "c2=";c1.display();
  33.         cout << "c2=";c2.display();
  34.         return 0;
  35.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top