Code:
#include <iostream>
using namespace std;
class product
{
private:
int count;
public:
void getcount()
{
cout<<"Plz enter the value of count = ";
cin>>count;
}
product (): count(6)
{ }
void operator ++()
{
++count;
cout<<"it is pre increment"<<endl;
}
void operator ++(int)
{
count++;
cout<<"it is post increment"<<endl;
}
void show()
{
cout<<"the value of count after increment is = "<<count<<endl;
}
};
class product1
{
private:
int count;
public:
void getcount()
{
cout<<"Plz enter the value of count = ";
cin>>count;
}
product ()
{count=6;}
void operator --()
{
--count;
cout<<"it is pre decrement"<<endl;
}
void operator --(int)
{
count--;
cout<<"it is post decrement"<<endl;
}
void show()
{
cout<<"the value of count after decrement is = "<<count<<endl;
}
};
void main()
{
product p;
p.getcount();
++p;
p.show();
p.getcount();
p++;
p.show();
product1 p1;
p1.getcount();
--p1;
p1.show();
p1.getcount();
p1--;
p1.show();
}
it is done in 2 classes it can also be done in 1 class