Overloading Unary operator In the following program the unary minus operator is used. A minus operator used as a unary, takes just one operand. /* Program that Shows how the unary minus operator is overloaded. */ #include<iostream> using namespace std; class simple { int x; int y; int z; public: void getdata(int a, int b, int c); void display(void); void operator-(); //overload unary minus }; void space::getdata(int a, int b, int c) { x=a; y=b; z=c; } void space::display(void) { cout<<"x="<<x<<" "; cout<<"y="<<y<<" "; cout<<"z="<<z<<" "; } void space::operator-() { x=-x; y=-y; z=-z; } int main(){ space S; S.getdata(...
This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.