Function overloading
#include <iostream>
using namespace std;class Test
{
private:
int x;
public:
Test():x(5){}
Test operator ++()
{
Test temp;
temp.x = x + 2;
return temp;
}
void show()
{
cout<<"Val: "<<x;
}
};
int main()
{
Test ob;
Test ob1 = ++ob;
ob1.show();
return 0;
}
Comments
Post a Comment