You are on page 1of 2

NAME:AKASH WARADE

STD:SE
DIV:I
ROLL NO:33
ASSIGN :operator over

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class complex
{
int real,imag;
complex()
{
real=0;
imag=0;
}
complex(int a,int b)
{
real=a;
imag=b;
}
public:
void display();
void add(complex);
};
void complex::display ()
{
cout<<real<<"+i"<<imag;
}
void complex::add(complex c)
{
complex temp;
temp.real=this->real+c.real;
temp.imag=this->imag+c.imag ;
return temp;
}
int main()
{
complex c1(10,20);
complex c2(15,30);
complex c3;
c1.display ();
c2.display ();
c3=c1.add (c2);
c3.display ();
return 0;
}

You might also like