Write a program to illustrate the concept of operator overloading in C++?
#include<iostream.h>
#include<conio.h>
class
a
{
public:
int
i,j;
public:
a()
{
i=10;
j=10;
}
public:
void
show()
{
cout<<"\n
After increment i is:"<<i;
cout<<"\n
After increment j is:"<<j;
}
public:
void
operator++()
{
i++;
j++;
}
};
void
main()
{
clrscr();
class
a a1;
++a1;
a1.show();
getch();
}
OUTPUT:-
After increment i is: 11
After increment j is: 11
Comments
Post a Comment