SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
FUNCTION OVERLOADING
Prof. K. Adisesha
Learning Outcomes
 Introduction
 Defining Function
 Function overloading
 Calling Overloaded Functions
 Inline Function
 Friend Function
2
Introduction
Function
 User defined function is a function defined by the user to
solve his/her problem.
 Such a function can be called from anywhere and any
number of times in the program.
 C++ implements polymorphism through function
overloading and operator overloading.
 Function overloading allows the user to create new
abstract data type.
3
Function Overloading
Function Overloading:
 Function Overloading means two or more
functions have same name, but differ in the
number of arguments or data types of
arguments.
 Function overloading is the process of defining
same function name to carry out similar types
of activities with various data items.
4
Function Overloading
Definition and Declaration of overloaded functions:
 The main factor in function overloading is a functions
argument list.
 If functions having same name with different types of
arguments or different number of arguments, then it is
invoked automatically by the compiler.
 Function Overloading is also known as Compile time
polymorphism.
 Example:
 int sum (int a, int b)
 float sum ( float p, float q);
. 5
Function Overloading
 To overload a function, each overloaded function must be
declared and defined separately.
 Example:
int product ( int p, int q, int r); //Definition of overloaded functions
float product ( float x, float y);
int product ( int p, int q, int r) //Declaration of overloaded functions
{
cout<<”Product = “<<p * q * r << endl;
}
float product ( float x, float y, float z);
{
cout<< “Product = “ << x * y <<endl;
}
6
Function Overloading
Need for function overloading:
 The advantage of function overloading are:
 Code is executed faster.
 It is easier to understand the flow of information
and debug.
 Code Maintenance is easy.
 Easier interface between programs and real world
objects.
7
Inline Function
Inline function:
 An Inline function is a special type of function whose body is
inserted at the place where it is called, instead of transferring
the control to the function.
 The keyword inline is used to define inline function.
 Rules:
 Inline function definition starts with keyword inline.
 The inline function should be defined before all function
that call it.
 The compiler replaces the function call statement with the
function code itself and then compiles the entire code.
8
Inline Function
Inline function:
 The general format for the inline function declaration is given
below.
 Syntax:
inline Returntype Fun_Name ( [Argument] )
{ ……….. ;
return expression;
}
 Example:
9
#include<iostream.h>
inline int cube( int a )
{
return a * a * a;
}
void main( )
{
cout<<“Cube of 3 is”<<cube(3);
return 0;
}
Inline Function
Advantage of inline function:
 The size of the object code is considerably reduced.
 The speed of execution of a program increases.
 Very efficient code can be generated.
 There is no burden on the system for function calling.
 It also saves the overhead of return call from a function.
 The readability of the program increases.
10
Inline Function
Disadvantage of inline function:
 May increase the size of the executable file
 More memory is needed.
 If used in header file, it will make your header file size
large and may also make it unreadable
The inline function may not work some times for one of
the following reasons:
 The inline function definition is too long or too complicated.
 The inline function is recursive.
 The inline function has looping constructs.
 The inline function has a switch or goto statement.
11
Friend Function
 A friend function is a non-member function of a class has
the access permission to the private member of the class.
 The friend function is declared within a class with the
prefix friend.
 But it should be defined outside the class like a normal
function without the prefix friend.
 The general format for the friend function is given below:
class class_name
{
public:
friend return_type function_name ( [arguments] );
}
12
Friend Function
Properties of friend functions:
 Friend function is a non-member function of the class, has full access
permission to members of the class.
 It can be declared either in public or private part of a class.
 A friend function cannot be called using the object of that class. It can be
invoked like any normal function.
 The function is declared with keyword friend. But while defining friend
function it does not use (: :) operator.
 They are normal external functions that are given special access privileges.
 It cannot access the data member variables directly and has to use an:
objectname.membername.
 Use of friend function is rare, since it violates the rule of encapsulation and
data hiding.
13
Friend Function
#include<iostream.h>
#include<conio.h>
class number
{
private:
int a;
public:
void readdata( )
{
cout<<”Enter the Number”<<endl;
cin>>a;
}
friend int even(number);
};
int even(number n)
{
if(n.a % 2 = = 0)
return 1;
else
return 0;
}
void main( )
{
number num1;
num1.readadata( );
if( even(num1) ) //friend function call
cout<<”Number is Even”;
else
cout<<’Number is Odd”;
}
14
Program to check a number is even or odd using a friend function
Discussion
Important Questions:
 What is function overloading? Explain the need for function
overloading.
 Discuss overloaded functions with syntax and example.
 What is inline function? Write a simple program for it.
 Mention the advantage and disadvantage of inline function.
 Explain friend function and their characteristics.
 Program to check whether a number is prime or not using
inline function.
15

Contenu connexe

Tendances

Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
asadsardar
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 

Tendances (20)

Function overloading
Function overloadingFunction overloading
Function overloading
 
06. operator overloading
06. operator overloading06. operator overloading
06. operator overloading
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
 
Files in c++
Files in c++Files in c++
Files in c++
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Class and object
Class and objectClass and object
Class and object
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
Friend function
Friend functionFriend function
Friend function
 
Functions in c
Functions in cFunctions in c
Functions in c
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 

Similaire à Function overloading

Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
nirajmandaliya
 
Chapter 13.1.6
Chapter 13.1.6Chapter 13.1.6
Chapter 13.1.6
patcha535
 
Prsentation on functions
Prsentation on functionsPrsentation on functions
Prsentation on functions
Alisha Korpal
 

Similaire à Function overloading (20)

chapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfchapter-8-function-overloading.pdf
chapter-8-function-overloading.pdf
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloading
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
 
DS Unit 6.ppt
DS Unit 6.pptDS Unit 6.ppt
DS Unit 6.ppt
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
Funtion
FuntionFuntion
Funtion
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Functions part1
Functions part1Functions part1
Functions part1
 
Fnctions part2
Fnctions part2Fnctions part2
Fnctions part2
 
c.p function
c.p functionc.p function
c.p function
 
My c++
My c++My c++
My c++
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Chapter 13.1.6
Chapter 13.1.6Chapter 13.1.6
Chapter 13.1.6
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Basic information of function in cpu
Basic information of function in cpuBasic information of function in cpu
Basic information of function in cpu
 
Prsentation on functions
Prsentation on functionsPrsentation on functions
Prsentation on functions
 

Plus de Prof. Dr. K. Adisesha

Plus de Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Function overloading

  • 2. Learning Outcomes  Introduction  Defining Function  Function overloading  Calling Overloaded Functions  Inline Function  Friend Function 2
  • 3. Introduction Function  User defined function is a function defined by the user to solve his/her problem.  Such a function can be called from anywhere and any number of times in the program.  C++ implements polymorphism through function overloading and operator overloading.  Function overloading allows the user to create new abstract data type. 3
  • 4. Function Overloading Function Overloading:  Function Overloading means two or more functions have same name, but differ in the number of arguments or data types of arguments.  Function overloading is the process of defining same function name to carry out similar types of activities with various data items. 4
  • 5. Function Overloading Definition and Declaration of overloaded functions:  The main factor in function overloading is a functions argument list.  If functions having same name with different types of arguments or different number of arguments, then it is invoked automatically by the compiler.  Function Overloading is also known as Compile time polymorphism.  Example:  int sum (int a, int b)  float sum ( float p, float q); . 5
  • 6. Function Overloading  To overload a function, each overloaded function must be declared and defined separately.  Example: int product ( int p, int q, int r); //Definition of overloaded functions float product ( float x, float y); int product ( int p, int q, int r) //Declaration of overloaded functions { cout<<”Product = “<<p * q * r << endl; } float product ( float x, float y, float z); { cout<< “Product = “ << x * y <<endl; } 6
  • 7. Function Overloading Need for function overloading:  The advantage of function overloading are:  Code is executed faster.  It is easier to understand the flow of information and debug.  Code Maintenance is easy.  Easier interface between programs and real world objects. 7
  • 8. Inline Function Inline function:  An Inline function is a special type of function whose body is inserted at the place where it is called, instead of transferring the control to the function.  The keyword inline is used to define inline function.  Rules:  Inline function definition starts with keyword inline.  The inline function should be defined before all function that call it.  The compiler replaces the function call statement with the function code itself and then compiles the entire code. 8
  • 9. Inline Function Inline function:  The general format for the inline function declaration is given below.  Syntax: inline Returntype Fun_Name ( [Argument] ) { ……….. ; return expression; }  Example: 9 #include<iostream.h> inline int cube( int a ) { return a * a * a; } void main( ) { cout<<“Cube of 3 is”<<cube(3); return 0; }
  • 10. Inline Function Advantage of inline function:  The size of the object code is considerably reduced.  The speed of execution of a program increases.  Very efficient code can be generated.  There is no burden on the system for function calling.  It also saves the overhead of return call from a function.  The readability of the program increases. 10
  • 11. Inline Function Disadvantage of inline function:  May increase the size of the executable file  More memory is needed.  If used in header file, it will make your header file size large and may also make it unreadable The inline function may not work some times for one of the following reasons:  The inline function definition is too long or too complicated.  The inline function is recursive.  The inline function has looping constructs.  The inline function has a switch or goto statement. 11
  • 12. Friend Function  A friend function is a non-member function of a class has the access permission to the private member of the class.  The friend function is declared within a class with the prefix friend.  But it should be defined outside the class like a normal function without the prefix friend.  The general format for the friend function is given below: class class_name { public: friend return_type function_name ( [arguments] ); } 12
  • 13. Friend Function Properties of friend functions:  Friend function is a non-member function of the class, has full access permission to members of the class.  It can be declared either in public or private part of a class.  A friend function cannot be called using the object of that class. It can be invoked like any normal function.  The function is declared with keyword friend. But while defining friend function it does not use (: :) operator.  They are normal external functions that are given special access privileges.  It cannot access the data member variables directly and has to use an: objectname.membername.  Use of friend function is rare, since it violates the rule of encapsulation and data hiding. 13
  • 14. Friend Function #include<iostream.h> #include<conio.h> class number { private: int a; public: void readdata( ) { cout<<”Enter the Number”<<endl; cin>>a; } friend int even(number); }; int even(number n) { if(n.a % 2 = = 0) return 1; else return 0; } void main( ) { number num1; num1.readadata( ); if( even(num1) ) //friend function call cout<<”Number is Even”; else cout<<’Number is Odd”; } 14 Program to check a number is even or odd using a friend function
  • 15. Discussion Important Questions:  What is function overloading? Explain the need for function overloading.  Discuss overloaded functions with syntax and example.  What is inline function? Write a simple program for it.  Mention the advantage and disadvantage of inline function.  Explain friend function and their characteristics.  Program to check whether a number is prime or not using inline function. 15