Could someone please tell me how to overload ++ operator in the postfix form. ++ sholud increment the instance variable avar of following class:
class A
{
int avar;
public:
A()
{
avar=0;
}
A(int a)
{
avar=a;
}
void display()
{
cout<<endl<<avar;
}
Could someone please tell me how to overload ++ operator in the postfix form. ++ sholud increment the instance variable avar of following class:
class A
{
int avar;
public:
A()
{
avar=0;
}
A(int a)
{
avar=a;
}
void display()
{
cout<<endl<<avar;
}
How about something like this:
class A
{
int avar;
public:
int operator++(int)
{
int temp = avar;
++avar;
return temp;
}
};
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.