#include<iostream.h>
#include<conio.h>
class mahi
{
float x,y;
public:
mahi()
{}
mahi(float real,float image)
{
x=real;
y=image;
}
mahi operator+(mahi);
void display(void);
};
mahi mahi::operator+(mahi c)
{
mahi temp;
temp.x=x+c.x;
temp.y=y+c.y;
return (temp);
}
void mahi::display(void)
{
cout<<x<<" And "<<y<<"\n";
}
void main()
{
clrscr();
mahi m1,m2,m3;
m1=mahi(2.5,3.5);
m2=mahi(1.4,2.6);
m3=m1+m2;
cout<<"\n M1= ";
m1.display();
cout<<"\n M2= ";
m2.display();
cout<<"\n M3= ";
m3.display();
getch();
}
#include<conio.h>
class mahi
{
float x,y;
public:
mahi()
{}
mahi(float real,float image)
{
x=real;
y=image;
}
mahi operator+(mahi);
void display(void);
};
mahi mahi::operator+(mahi c)
{
mahi temp;
temp.x=x+c.x;
temp.y=y+c.y;
return (temp);
}
void mahi::display(void)
{
cout<<x<<" And "<<y<<"\n";
}
void main()
{
clrscr();
mahi m1,m2,m3;
m1=mahi(2.5,3.5);
m2=mahi(1.4,2.6);
m3=m1+m2;
cout<<"\n M1= ";
m1.display();
cout<<"\n M2= ";
m2.display();
cout<<"\n M3= ";
m3.display();
getch();
}
No comments:
Post a Comment