I need an easy example. I know basic overloading of operators like +,-,*,<<,>> etc. And please help to complete my code.
#include<iostream>
using namespace std;
class XY
{
int x,y;
public:
XY()
{
x=0;y=0;
}
friend ostream &operator<<( ostream &output,const XY &D )
{
output << "X : " << D.x << " Y: " << D.y;
return output;
}
friend istream &operator>>( istream &input,XY &D )
{
input >> D.x >> D.y;
return input;
}
-> overloading starts here
XY* operator ->()
{
}
};
int main()
{
XY a;
cout<<"Enter value of x & y "<<endl;
cin>>a;
cout<<a;
//way to access members
cout<<a;
}