QUESTION: Design a Class for complex number and write a program in C++ to overload binary
operator + for adding two complex numbers.
ANSWER:
operator + for adding two complex numbers.
ANSWER:
#include class Complex { private: int real, imag; public: Complex(int r = 0, int i =0) { real = r; imag = i; } // This is automatically called when '+' is used with // between two Complex objects Complex operator + (Complex const &obj) { Complex res; res.real = real + obj.real; res.imag = imag + obj.imag; return res; } void print() { cout
RESULT:
12+ i9