#include<iostream.h>
#include<conio.h>
class demo
{
int a;
int b;
int c;
public:
demo()
{
a=10;
b=20;
}
void show()
{
cout<<"\n Sum is "<<c;
}
demo operator+(demo);
};
demo demo::operator+(demo d)
{
demo temp;
temp.a=a+d.a;
temp.b=b+d.b;
temp.c=temp.a+temp.b;
return temp;
}
void main()
{
demo d1,d2,d3;
d3=d1+d2;
d3.show();
getch();
}
#include<conio.h>
class demo
{
int a;
int b;
int c;
public:
demo()
{
a=10;
b=20;
}
void show()
{
cout<<"\n Sum is "<<c;
}
demo operator+(demo);
};
demo demo::operator+(demo d)
{
demo temp;
temp.a=a+d.a;
temp.b=b+d.b;
temp.c=temp.a+temp.b;
return temp;
}
void main()
{
demo d1,d2,d3;
d3=d1+d2;
d3.show();
getch();
}
No comments:
Post a Comment