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

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart