Operator Overloading
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
/* In operator overloading an operator behaves differently depending on its operands. */
int main()
{
// Here we are overloading + operator
int a=10,b=20,c;
c=a+b;
cout<< "Value of c :" << c << endl; // For numeric operands it produces their sum.
string d="Hello ",e="World..!!",f;
f=d+e;
cout<< f; // For string operands it produces their concatenated string.*/
return 0;
}
Output:
Value of c :30
Hello World..!!