Binary Operator Overloading in C++

Operator Overloading means overloading an operator.We can write function as normal but Function name is keyword(reserved keyword) "operator" with symbol(operator+).We can used this to overload the addition operator.

Binary Operator Overloading

#include<iostream.h>
#include<conio.h>
class score
{
public:
int val,val1;
score()  //constructor without argument
{
val=5;
val1=10;
}
score operator+(score s) //operator overloading
{
score temp;
temp.val=s.val+s.val1;
return temp;
}};
void main()
{
clrscr();
score s1,s2,s3;
s3=s1+s2;
cout<<s1.val<<endl;
cout<<s2.val<<endl;
cout<<s3.val;
getch();
}

binary operator