#include <iostream.h>
#include <conio.h>
class Complex
{
private :
float x;
float y;
public :
void getData(float a, float b)
{
x = a;
y = b;
}
void showData( )
{
Cout<<x<<y<<”\n”;
}
Complex operator + (Complex c2)
{
Complex c3;
c3.x = x + c2.x;
c3.y = y + c2.y;
return( c3);
}
};
void main( )
{
Complex p1, p2, p3;
p1.getData(10,20);
p2.getData(30,40);
p3 = p1 + p2;
p3.showData( );
}
Output :
40 60
#include <conio.h>
class Complex
{
private :
float x;
float y;
public :
void getData(float a, float b)
{
x = a;
y = b;
}
void showData( )
{
Cout<<x<<y<<”\n”;
}
Complex operator + (Complex c2)
{
Complex c3;
c3.x = x + c2.x;
c3.y = y + c2.y;
return( c3);
}
};
void main( )
{
Complex p1, p2, p3;
p1.getData(10,20);
p2.getData(30,40);
p3 = p1 + p2;
p3.showData( );
}
Output :
40 60
0 comments:
Post a Comment