#include
#include
class complex
{
float x,y;
public:
complex() {}
complex(float real,float img)
{
x=real; y=img;
}
complex operator+(complex);
complex operator-(complex);
complex operator*(complex);
void display()
{
cout<
};
complex complex::operator+(complex c)
{
complex temp;
temp.x=x+c.x;
temp.y=y+c.y;
return(temp);
}
complex complex::operator-(complex d)
{
complex temp;
temp.x=x-d.x;
temp.y=y-d.y;
return(temp);
}
complex complex::operator*(complex e)
{
complex temp;
temp.x=x*e.x+y*e.y*(-1);
temp.y=x*e.y+y*e.x;
return(temp);
}
void main()
{
clrscr();
complex c1(5,3),c2(3,2),c3=c1+c2,c4=c1-c2,c5=c1*c2;
c1.display();
c2.display();
cout<<"Addition"<
cout<<"Subtraction"<
cout<<"Multiplication"<
getch();
}
No comments:
Post a Comment