You are on page 1of 2

#include<iostream.

h>
#include<conio.h>
class complex
{
float real,img;
public:
void getdata()
{
cout<<"\nEnter the real number->";
cin>>real;
cout<<"\nEnter the imaginary number->";
cin>>img;
}
void show_add_data()
{
cout<<"\nThe addition of complex numbers is->"<<real<<"+"<<img<<"i\n";
}
void show_mul_data()
{
cout<<"\nThe multiplication of complex number is->"<<real<<"*"<<img<<"i\n";
}
complex operator+(complex c)
{
complex t;
t.real=real+c.real;
t.img=img+c.img;
return t;
}
complex()
{
cout<<"Constucting\n";
}
~complex()
{
cout<<"Destructing\n";
}
};
void main()
{
complex c1,c2,c3,c4;
c1.getdata();
c2.getdata();
c3=c1+c2;
c3.show_add_data();
c4.show_mul_data();
getch();
}

You might also like