SlideShare a Scribd company logo
NAME: DHWANI HINGORANI
ENR NO: 170410107025
SUBJECT: OBJECT ORIENTED
PROGRAMMING WITH C++
INLINE
FUNCTIONS
INLINE
FUNCTIONS
 The inline functions are a C++
enhancement feature to increase the
execution time of a
program. Functions can be instructed to
compiler to make them inline so that
compiler can replace
those function definition wherever those
are being called.
 Compiler replaces the definition of inline
functions at compile time instead of
referring function definition at runtime.
::-EXAMPLE-::
Class A
{
Public:
inline int add(int a, int b)
{
return (a + b);
};
}
Class A
{
Public:
int add(int a, int b);
};
inline int A::add(int a, int b)
{
return (a + b);
}
PROS OF INLINE FUNCTIONS
1. It speeds up your program by avoiding function calling
overhead.
2. It save overhead of variables push/pop on the stack, when
function calling happens.
3. It save overhead of return call from a function.
4. It increases locality of reference by utilizing instruction cache.
5. By marking it as inline, you can put a function definition in a
header file (i.e. it can be included in multiple compilation
unit, without the linker complaining)
CONS OF INLINE FUNCTIONS
1. It increases the executable size due to code expansion.
2. C++ inlining is resolved at compile time. Which means if you
change the code of the inlined function, you would need to
recompile all the code using it to make sure it will be updated.
3. When used in a header, it makes your header file larger with
information which users don’t care.
4. As mentioned above it increases the executable size, which may
cause thrashing in memory. More number of page fault bringing
down your program performance.
5. Sometimes not useful for example in embedded system where
large executable size is not preferred at all due to memory
constraints.
WHEN TO USE?
Function can be made as inline as per programmer need. Some
useful recommendation are mentioned below-
1. Use inline function when performance is needed.
2. Use inline function over macros.
3. Prefer to use inline keyword outside the class with the function
definition to hide implementation details.
THANK YOU!

More Related Content

What's hot (20)

PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPT
Operator overloading in C++
BalajiGovindan5
 
PPTX
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
Simplilearn
 
PPTX
Inline Functions and Default arguments
Nikhil Pandit
 
PDF
Operator overloading C++
Lahiru Dilshan
 
PDF
Function overloading ppt
Prof. Dr. K. Adisesha
 
PPTX
Constructor ppt
Vinod Kumar
 
PPTX
Classes and objects
rajveer_Pannu
 
PPTX
Variables in C++, data types in c++
Neeru Mittal
 
PPTX
Templates in C++
Tech_MX
 
PPTX
Function overloading and overriding
Rajab Ali
 
PPTX
Inheritance in c++
Paumil Patel
 
PPTX
Functions in c++
Rokonuzzaman Rony
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPTX
Types of Constructor in C++
Bhavik Vashi
 
PPT
FUNCTIONS IN c++ PPT
03062679929
 
PPT
friend function(c++)
Ritika Sharma
 
PPTX
Functions in C
Shobhit Upadhyay
 
PPTX
Friend functions
Megha Singh
 
PPTX
Functions in c
sunila tharagaturi
 
Oop c++class(final).ppt
Alok Kumar
 
Operator overloading in C++
BalajiGovindan5
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
Simplilearn
 
Inline Functions and Default arguments
Nikhil Pandit
 
Operator overloading C++
Lahiru Dilshan
 
Function overloading ppt
Prof. Dr. K. Adisesha
 
Constructor ppt
Vinod Kumar
 
Classes and objects
rajveer_Pannu
 
Variables in C++, data types in c++
Neeru Mittal
 
Templates in C++
Tech_MX
 
Function overloading and overriding
Rajab Ali
 
Inheritance in c++
Paumil Patel
 
Functions in c++
Rokonuzzaman Rony
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Types of Constructor in C++
Bhavik Vashi
 
FUNCTIONS IN c++ PPT
03062679929
 
friend function(c++)
Ritika Sharma
 
Functions in C
Shobhit Upadhyay
 
Friend functions
Megha Singh
 
Functions in c
sunila tharagaturi
 

Similar to Inline functions (20)

PDF
inline function
SAURABH SHARMA
 
PPTX
inline function
imran khan
 
DOCX
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Faisal Shehzad
 
PPTX
INLINE FUNCTIONS IOT68.pptx
ZalakPatel228771
 
PPTX
Inline functions in c++
Harish Gyanani
 
PPT
Object oriented programming using c++
Trinity Dwarka
 
PPTX
Function in C++, Methods in C++ coding programming
estorebackupr
 
PPTX
06 - This pointer, Inline, Array of Objects.pptx
trailersmovie
 
PPTX
Inline function in C++
Jenish Patel
 
DOCX
Inline function(oops)
Jay Patel
 
PPSX
Chapter-4_OOP aare temi Lena na petna chho loda
kongshi9999
 
PPTX
Inline function in C++
Learn By Watch
 
PPTX
Study of Inline Function in C++ with examples
JayashreeJankarTamkh
 
PPTX
Object Oriented Programming using C++ Unit 1
NageshPratapSingh2
 
PPT
Functions in C++
Mohammed Sikander
 
PDF
Function overloading
Prof. Dr. K. Adisesha
 
PPTX
Programming in c++ ppt
sujathavvv
 
PPTX
Programming in c++ ppt
MalarMohana
 
PDF
Computer_Programming_Part_II_Segment_02.pdf
et243047
 
PPTX
wepik-mastering-function-in-c-a-comprehensive-guide-20231220121719HZHU.pptx
avishekpradhan24
 
inline function
SAURABH SHARMA
 
inline function
imran khan
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Faisal Shehzad
 
INLINE FUNCTIONS IOT68.pptx
ZalakPatel228771
 
Inline functions in c++
Harish Gyanani
 
Object oriented programming using c++
Trinity Dwarka
 
Function in C++, Methods in C++ coding programming
estorebackupr
 
06 - This pointer, Inline, Array of Objects.pptx
trailersmovie
 
Inline function in C++
Jenish Patel
 
Inline function(oops)
Jay Patel
 
Chapter-4_OOP aare temi Lena na petna chho loda
kongshi9999
 
Inline function in C++
Learn By Watch
 
Study of Inline Function in C++ with examples
JayashreeJankarTamkh
 
Object Oriented Programming using C++ Unit 1
NageshPratapSingh2
 
Functions in C++
Mohammed Sikander
 
Function overloading
Prof. Dr. K. Adisesha
 
Programming in c++ ppt
sujathavvv
 
Programming in c++ ppt
MalarMohana
 
Computer_Programming_Part_II_Segment_02.pdf
et243047
 
wepik-mastering-function-in-c-a-comprehensive-guide-20231220121719HZHU.pptx
avishekpradhan24
 
Ad

Recently uploaded (20)

PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Ad

Inline functions

  • 1. NAME: DHWANI HINGORANI ENR NO: 170410107025 SUBJECT: OBJECT ORIENTED PROGRAMMING WITH C++ INLINE FUNCTIONS
  • 2. INLINE FUNCTIONS  The inline functions are a C++ enhancement feature to increase the execution time of a program. Functions can be instructed to compiler to make them inline so that compiler can replace those function definition wherever those are being called.  Compiler replaces the definition of inline functions at compile time instead of referring function definition at runtime.
  • 3. ::-EXAMPLE-:: Class A { Public: inline int add(int a, int b) { return (a + b); }; } Class A { Public: int add(int a, int b); }; inline int A::add(int a, int b) { return (a + b); }
  • 4. PROS OF INLINE FUNCTIONS 1. It speeds up your program by avoiding function calling overhead. 2. It save overhead of variables push/pop on the stack, when function calling happens. 3. It save overhead of return call from a function. 4. It increases locality of reference by utilizing instruction cache. 5. By marking it as inline, you can put a function definition in a header file (i.e. it can be included in multiple compilation unit, without the linker complaining)
  • 5. CONS OF INLINE FUNCTIONS 1. It increases the executable size due to code expansion. 2. C++ inlining is resolved at compile time. Which means if you change the code of the inlined function, you would need to recompile all the code using it to make sure it will be updated. 3. When used in a header, it makes your header file larger with information which users don’t care. 4. As mentioned above it increases the executable size, which may cause thrashing in memory. More number of page fault bringing down your program performance. 5. Sometimes not useful for example in embedded system where large executable size is not preferred at all due to memory constraints.
  • 6. WHEN TO USE? Function can be made as inline as per programmer need. Some useful recommendation are mentioned below- 1. Use inline function when performance is needed. 2. Use inline function over macros. 3. Prefer to use inline keyword outside the class with the function definition to hide implementation details.