#include<iostream.h>
class load
{
int m,n;
public:
load()
{
{
m++;
n++;
}
void main()
{
load x1(100,200);
x1++;
++x1;
x1.display();
}
If the overload increment function declares as friend function then it will take a single argument.
class load
{
int m,n;
public:
load()
{
m=0, n=0;}
load(int a, int b)
{
load(int a, int b)
{
m=a;
n=b;
n=b;
}
void display()
{
{
cout<<m<<"\n";
cout<<n<<"\n";
cout<<n<<"\n";
}
void operator++();
};
void load ::operator++() void operator++();
};
{
m++;
n++;
}
void main()
{
load x1(100,200);
x1++;
++x1;
x1.display();
}
Sample Output:
friend void operator++(load &); //function declaration
void operator++(load &x)
{
x.m++;
x.n++;
}
void operator++(load &x)
{
x.m++;
x.n++;
}
Tags:
Cpp