//BCA Support
//www.bcasupport.xyz
#include <iostream.h>
#include <conio.h>
class coord
{
int x,y;
public:
coord() {}
coord(int a,int b)
{
x=a;
y=b;
}
void show()
{
cout<<x<<","<<y;
}
coord operator++()
{
coord temp;
++x;
++y;
temp.x=x;
temp.y=y;
return temp;
}
coord operator--()
{
coord temp;
--x;
--y;
temp.x=x;
temp.y=y;
return temp;
}
coord operator++(int)
{
coord temp;
temp.x=x;
temp.y=y;
x++;
y++;
return temp;
}
coord operator--(int)
{
coord temp;
temp.x=x;
temp.y=y;
x--;
y--;
return temp;
}
};
int main()
{
clrscr();
coord a(5,5),b;
cout<<"\nCurrent coords : ";
a.show();
b=++a;
cout<<"\nCords after Prefix ++ : ";
b.show();
b=--a;
cout<<"\nCords after Prefix -- : ";
b.show();
b=a++;
cout<<"\nCords after Postfix ++ : ";
b.show();
b=a--;
cout<<"\nCoords after Postfix -- : ";
b.show();
cout<<"\nFinal coords : ";
a.show();
getch();
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.