#include <iostream>
usingnamespace std;
class Complex
{
private:
int a;
int b;
public:
Complex();
Complex(int x, int y, char *str);
Complex Suma(Complex z);
~Complex();
};
Complex::Complex()
{
a = 0;
b = 0;
}
Complex::Complex(int x, int y, char *str)
{
cout << "\n Give the " << str <<endl;
cout << "\n\t Give the real part : ";
cin >> x;
a = x;
cout << "\n\t Give the imaginary part : ";
cin >> y;
b = y;
}
Complex::Complex Suma(Complex z)
{
Complex Z;
Z.a = a + z.a;
Z.b = b + z.b;
return Z;
}
int main()
{
int x, y;
Complex R(), R(x, y, "first number"), R(x, y, "second number");
return 0;
}
#include <iostream>
usingnamespace std;
class Complex
{
private:
int a;
int b;
public:
Complex();
Complex(int x, int y, constchar *str);
Complex Suma(Complex z);
~Complex();
};
Complex::Complex()
{
a = 0;
b = 0;
}
Complex::Complex(int x, int y, constchar *str)
{
cout << "\n Give the " << str <<endl;
cout << "\n\t Give the real part : ";
cin >> x;
a = x;
cout << "\n\t Give the imaginary part : ";
cin >> y;
b = y;
}
Complex::~Complex()
{}
Complex Complex::Suma(Complex z)
{
Complex Z;
Z.a = a + z.a;
Z.b = b + z.b;
return Z;
}
int main()
{
int x, y;
Complex R(), R1(x, y, "first number"), R2(x, y, "second number");
return 0;
}