#include <iostream>
using namespace std;
class decrement
{
int a;
public:
decrement()
{
a=0;
}
decrement(int x)
{
a=x;
}
operator--(int)
{
a--;
}
operator--()
{
--a;
}
void print();
};
void decrement::print()
{
cout << endl << "a=" << a << endl ;
}
int main()
{
decrement d1(4);
d1.print();
d1--;
d1.print();
decrement d2(100);
d2.print();
--d2;
d2.print();
return 0;
}
C and C++ programs, games, softwares. Easy programming guide. Learn to code and enjoy coding in CoderNepal
Home » T.U.2071 » C++ code for Unary Operator Overloading (--)
Monday, April 17, 2017
C++ code for Unary Operator Overloading (--)
This is the solution that decreases an integer value by 1 by overloaded operator (T.U. 2071)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment