List of operators that cannot be overloaded.
Increment the time using ++
Decrement the time using ++
Add two object using “+” operator with friend function
class distance (feet,inches) with “+” operator
class distance (feet,inches) with “+” operator with friend function
class distance (km,m) with “+” operator
class distance (km,m) with “+” operator with friend function
class distance (m,cm) with “+” operator
class distance (m,cm) with “+” operator with friend function
class distance (km,m,cm) with “+” operator
class distance (km,m,cm) with “+” operator with friend function
class distance (km,m,cm,mm) with “+” operator
class distance (km,m,cm,mm) with “+” operator with friend function
class time(hh,mm,ss) with “+” operator
class time(hh,mm,ss) with “+” operator with friend function
class complex(real,ing) with “+” operator
class complex(real,ing) with “+” operator with friend function
class string(str) with “+” operator
class string(str) with “+” operator with friend function

Example:8

```// to overload ++ operator (with more data elements)
// with 2 data elements
#include<iostream>
#include<conio.h>
using namespace std;
class sample
{
int a,b;
public:
sample();
sample(int n1,int n2);
void get();
void disp();
void operator++();
};
sample::sample()
{
a=0;
b=0;
}
sample::sample(int n1,int n2)
{
a=n1;
b=n2;

}
void sample::get()
{
cout<<"Enter the value of a and b ";
cin>>a>>b;
}
void sample::disp()
{
cout<<"a= "<<a<<" b= "<<b<<endl;
}
void sample::operator++()
{
a=a+1;
b=b+1;
}

int main()
{
sample s1,s2;
s1.get();s2.get();
s1.disp();s2.disp();
++s1;
++s1;
++s1;
++s2;
s1.disp();s2.disp();
return(0);
getch();
}```

Output

Example:9

```// to overload ++ operator (with more data elements)
// with 2 data elements
#include<iostream>
#include<conio.h>
using namespace std;
class sample
{
int a,b;
public:
sample();
sample(int n1,int n2);
void get();
void disp();
void operator--();
};
sample::sample()
{
a=0;
b=0;
}
sample::sample(int n1,int n2)
{
a=n1;
b=n2;

}
void sample::get()
{
cout<<"Enter the value of a and b ";
cin>>a>>b;
}
void sample::disp()
{
cout<<"a= "<<a<<" b= "<<b<<endl;
}
void sample::operator--()
{
a=a-1;
b=b-1;
}

int main()
{
sample s1,s2;
s1.get();s2.get();
s1.disp();s2.disp();
--s1;
--s1;
--s1;
--s2;
s1.disp();s2.disp();
return(0);
getch();
}
```

Output:

Example:10

```// to overload - operator (with more data elements)
#include<iostream>
#include<conio.h>
using namespace std;
class sample
{
private:
int a,b;
public:
sample();//default constructor
sample(int n1,int n2);//para cons
void get();
void disp();
void operator-();
};
sample::sample()
{
a=0;
b=0;
}
sample::sample(int n1,int n2)
{
a=n1;
b=n2;
}
void sample::get()
{
cout<<"Enter the value of a and b ";
cin>>a>>b;
}
void sample::disp()
{
cout<<"a = "<<a<<endl;
cout<<"b = "<<b<<endl;
}
void sample::operator-()
{
a=-a;//a=a*-1;
b=-b;//b=b*-1;
}

int main()
{
sample s1,s2;
s1.get();s2.get();
s1.disp();s2.disp();
-s1;   //s1.operator-();
-s2;
s1.disp();s2.disp();
getch();
return(0);
}```

Output:

Important Pages