Overloading Binary Operator in C++ Programming
#include<iostream.h>
#include<conio.h>
class Test
{
public:
int value;
Test(int i);
void show();
Test operator +(Test.&T1);
Test operator +(int 1);
};
Test::Test(int i)
{
value=i;
}
void Test::show()
{
cout<<"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()
{
clrscr();
Test T2(10),T3(25);
T2.show();
T2=T3+100;
T2.show();
getch();
}
0 coment�rios:
Post a Comment