Overloading UNARY MINUS
<iostream>
using namespace std;
class space
{
x;
y;
z;
:
getdata(a, b, c);
display();
operator~();
};
space:: getdata( a,b, c)
{
x=a;
y=b;
z=c;
}
space:: display()
{
std::cout<< x <<" ";
std::cout<< y <<" ";
std::cout<< z <<"\n";
}
space :: operator~()
{
x=-x;
y=-y;
z=-z;
}
main()
{
space s;
s.getdata(10,-20,30);
std::cout<<"S :";
s.display();
0;
}
|