write a program to overload the function ++ and -- for the prifix and suffix in c++
// write a program to overload the function ++ and -- for the prifix and suffix
#include<iostream>
using namespace std;
class number
{
float x;
public:
number(float k)
{
x=k;;
}
void operator ++(int)
{
x++;
}
void operator --()
{
--x;
}
void show()
{
cout<<"\n x="<<x;
}
};
int main()
{
number N(2.3);
cout<<"/n befor the incrimination";
N.show();
cout<<"\n after incrimination :";
N++;
N.show();
cout<<"\n after discrimination";
--N;
N.show();
}
Comments
Post a Comment