PRESENTATION
OBJECT ORIENTED PROGRAMMING
GROUP MEMBERS
ANSA BASHIR
IQRA JAVED
AFSHAN MUBEEN
TOPIC:
OPERATOR OVERLOADING
What is overloading?
• Multiple functions , same name , different
types or amount of parameters.
• Two type is:
1. Method overloading
2. Operator overloading
OPERATOR OVERLOADING
“Process of defining additional meanings of an
operator”.
EXAMPLE:
Additonal operator(+) is used to add two
numeric values.
c= a+b
TYPES OF OPERATOR OVERLOADING.
• Unary operator overloading.
• Binary operator overloading.
Operator Overloading…..
.syntax
return _type operator op ()
{
function body;
}
Overloading unary operators
“Operator that works with single operand”.
Unary operators that can be overloaded in C++…
+ _ * ! ~ &
++ _ _ -> () delete new
Program:
write a program that overload increment operator to work with user-defined objects.
#include <iostream.h>
#include <conio.h>
class count
{
private:
int n;
public:
count( )
{
n=0;
}
void show( )
{
cout<<“n= “<<n<<endl’
}
void operator++( )
{
n=n+1;

Presentation1.pptx