Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- class ovrld
- {
- public:
- int x;
- void display();
- void operator-()
- {
- x=-x;
- }
- };
- void ovrld::display()
- {
- cout<<"the integer value is:\n"<<x<<endl;
- }
- int main()
- {
- ovrld s;
- cout<<"enter a integer value to negate it\n";
- cin>>s.x;
- cout<<"value before negation is:\n";
- s.display();
- -s;
- cout<<"value after negation is:\n";
- s.display();
- return 0;
- }
- OUTPUT:
- enter a integer value to negate it
- 3
- value before negation is:
- the integer value is:
- 3
- value after negation is:
- the integer value is:
- -3
- Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment