#include<iostream.h>
#include<conio.h>
class image;
class real
{
private :
int x1 , y1;
public :
void getdata();
friend int sum(real, image);
};
void real :: getdata()
{
cout<<"Enter the real and imaginary part of first complex no.";
cout<<endl<<"Real part :";
cin>>x1;
cout<<"Imaginary part : ";
cin>>y1;
}
class image
{
private :
int x2, y2;
public :
void getdata();
friend int sum (real, image);
};
void image :: getdata()
{
cout<<"Enter the real and imaginary part of second complex no.";
cout<<"Real part : ";
cin>>x2;
cout<<"Imaginary part : ";
cin>>y2;
}
int sum(real obj1, image obj2)
{
int a, b;
a = obj1.x1 + obj2.x2;
b = obj1.y1 + obj2.y2;
cout<<endl<<"The result of the sum of two complex no. is : ";
cout<<a<<" + i" <<b;
}
int main()
{
class real r;
class image i;
clrscr();
r.getdata();
i.getdata();
sum(r,i);
getch();
return (0); }