Sunday, 30 March 2014

Overloading Unery Operators(++,- -)

#include<iostream.h>
Class Unery
{
int x,y;
Public:
         void Input();
         void Display();
void operator ++(int); 
void operator--(int);
  }


void main()
{
Unery ob1,ob2;
ob1.Input();
ob1.Display(); 
ob1++;
cout<<"\n After Increment";
ob1.Display();

ob1--;
cout<<"\n After Decrement";
ob1.Display();
} 
void Unery::Input()
{
cout<<"\n Enter x & y";
cin>>x>>y;
} 
void Unery::Display()
{
cout<<"\n X:"<<x<<"\nY:"<<y;
}
void Unery::operator++()
{
x++;
y++;
}
void Unery::operator--()
{
x--;
y--;
}

No comments:

Post a Comment