Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Complex
- {
- private:
- float real;
- float imag;
- public:
- Complex():real(0), imag(0){}
- Complex operator ()(float re, float im)
- {
- real += re;
- imag += im;
- return *this;
- }
- Complex operator() (float re)
- {
- real += re;
- return *this;
- }
- void display()
- {
- cout << "(" << real << "," << imag << ")" << endl;
- }
- };
- int main()
- {
- Complex c1, c2;
- c2 = c1(3.2, 5.3);
- c1(6.5, 2.7);
- c2(1.9);
- cout << "c2=";c1.display();
- cout << "c2=";c2.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement