Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- class opr
- {
- int c;
- public:
- opr()
- {
- c=0;
- }
- opr(int a)
- {
- c=a;
- }
- void operator++()
- {
- c=c+1;
- }
- void operator--()
- {
- c=c-1;
- }
- void display()
- {
- cout<<c<<"\n";
- }
- };
- int main()
- {
- int x;
- opr s1;
- cout<<"enter a number:\n";
- cin>>x;
- s1=opr(x);
- ++s1;
- cout<<"after incrementing ";
- s1.display();
- --s1;
- cout<<"after decrementing ";
- s1.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment