Here's a program to add two complex numbers of two different classes: #include <iostream> using namespace std; class Complex1 { private: double real; double imag; public: Complex1(double r = 0, double i = 0) { real = r; imag = i; } void display() { cout << real << " + " << imag << "i" << endl; } }; class Complex2 { private: double real; double imag; public: Complex2(double r = 0, double i = 0) { real = r; imag = i; } void display() { cout << real << " + " << imag << "i" << endl; } Complex2 operator+(const Complex1& c1) { Complex2 temp; ...
This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.