#include <iostream> using namespace std; class coord{ int x=0,y=0; public: coord () { x=0;y=0; } int set_xy (int i=0, int j=0) { cout<<"\nFor two operants like x and y\n"; cout<<"Enter x="; cin>>i; cout<<"Enter y="; cin>>j; x=i; y=j; } void get_xy (int &a, int &b) { a=x;b=y; } coord operator+(coord ob2); coord operator-(coord ob2); coord operator*(coord ob2); coord operator/(coord ob2); coord operator=(coord ob2); }; coord coord::operator+(coord ob2) { coord temp; temp.x=x+ob2.x; temp.y=y+ob2.y; return temp; } coord coord::operator-(coord ob2) { coord temp; temp.x=x-ob2.x; temp.y=y-ob2.y; return temp; } coord coord::operator*(coord ob2) { coord temp; temp.x=x*ob2.x; temp.y=y*ob2.y; return temp; } coord coord::operator/(coord ob2) { coord temp; temp.x=x/ob2.x; temp.y=y/ob2.y; return temp; } coord coord::operator=(coord ob2) { x=ob2.x; y=ob2.y; return *this; } int main() { coord o1,o2,o3; int m,n; int a; cout<<"For Addition, enter 1\nFor Subtraction, enter 2\nFor Multiplication, enter 3\nFor Division, enter 4\nFor Replacing, enter 5\n"; cin>>a; if(a==1) { o1.set_xy(); o2.set_xy(); o3=o1+o2; o3.get_xy(m,n); cout <<"\nAfter addition x=" <<m<<" and y="<<n<<"\n"; } else if(a==2) { o1.set_xy(); o2.set_xy(); o3=o1-o2; o3.get_xy(m,n); cout <<"\nAfter subtraction x=" <<m<<" and y="<<n<<"\n"; } else if(a==3) { o1.set_xy(); o2.set_xy(); o3=o1*o2; o3.get_xy(m,n); cout <<"\nAfter multiplication x=" <<m<<" and y="<<n<<"\n"; } else if(a==4) { o1.set_xy(); o2.set_xy(); o3=o1/o2; o3.get_xy(m,n); cout <<"\nAfter division x=" <<m<<" and y="<<n<<"\n"; } else if(a==5) { o1.set_xy(); o2.set_xy(); o3=o1=o2; o3.get_xy(m,n); cout <<"\nAfter replacing x=" <<m<<" and y="<<n<<"\n"; } return 0; }