#include<iostream.h>
#include<conio.h>
class Test
{
public:
int value;
Test(int i);
void show();
Test operator+(Test &T1);
Test operator+(int i);
};
Test::Test(int i)
{
value=i;
}
void Test::show()
{
cout<<"\n The Value is :"<<value<<endl;
}
Test Test::operator+(Test &T1)
{
value=T1.value+value;
return value;
}
Test Test::operator+(int i)
{
value=value+i;
return value;
}
void main()
{
Test T2(10),T3(25);
clrscr();
T2=T2+T3;
T2.show();
T2=T3+100;
T2.show();
getch();
}
#include<conio.h>
class Test
{
public:
int value;
Test(int i);
void show();
Test operator+(Test &T1);
Test operator+(int i);
};
Test::Test(int i)
{
value=i;
}
void Test::show()
{
cout<<"\n The Value is :"<<value<<endl;
}
Test Test::operator+(Test &T1)
{
value=T1.value+value;
return value;
}
Test Test::operator+(int i)
{
value=value+i;
return value;
}
void main()
{
Test T2(10),T3(25);
clrscr();
T2=T2+T3;
T2.show();
T2=T3+100;
T2.show();
getch();
}
No comments:
Post a Comment