PRESENTATION TOPIC
INSLINE FUNCTION
REPRRESENTATOR :
IMRAN KHAN
FAHAD NUOMAN
Contents :
 INLINE FUNCTION
 Syntax
 Example
 USES
 ADVANTAGES
 DISADVANTAGES
What is inline function ?
 INLINE FUNCTION :
 . If a function is inline, the compiler places a
copy of the code of that function at each
point where the function is called at
compile time
Syntax of inline function
 Inline return _type fun_name (arguments)
 #include<iostream>
 using namespace std;
 inline int max(int x, int y)
 {
 return (x>y) ? x : y;
 }
 int main()
 {
 int a,b;
 cout<<"enter value for a"<<endl;
 cin>>a;
 cout<<"enter value for b"<<endl;
 cin>>b;
 cout<<"greater value is"<<max( a,b );

 return 0;
Working procedure of inline functions
Uses Of INLINE FUNCTION :
To reduce and save the memory space .
The inline function is just a code replacement
instead of the function call .
inline is a hint or request to compiler and its
used to avoid function call overheads.
Advantages:-
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.
1. 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)
Disadvantages:-
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.
 As mentioned above it increases the
executable size, which may cause thrashing
in memory. More number of page fault
bringing down your program performance.
inline function

inline function

  • 2.
  • 3.
    Contents :  INLINEFUNCTION  Syntax  Example  USES  ADVANTAGES  DISADVANTAGES
  • 4.
    What is inlinefunction ?  INLINE FUNCTION :  . If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at compile time
  • 5.
    Syntax of inlinefunction  Inline return _type fun_name (arguments)
  • 6.
     #include<iostream>  usingnamespace std;  inline int max(int x, int y)  {  return (x>y) ? x : y;  }  int main()  {  int a,b;  cout<<"enter value for a"<<endl;  cin>>a;  cout<<"enter value for b"<<endl;  cin>>b;  cout<<"greater value is"<<max( a,b );   return 0;
  • 7.
    Working procedure ofinline functions
  • 8.
    Uses Of INLINEFUNCTION : To reduce and save the memory space . The inline function is just a code replacement instead of the function call . inline is a hint or request to compiler and its used to avoid function call overheads.
  • 9.
    Advantages:- 1. It speedsup 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.
  • 10.
    1. By markingit 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)
  • 11.
    Disadvantages:- 1. It increasesthe 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.
  • 12.
     As mentionedabove it increases the executable size, which may cause thrashing in memory. More number of page fault bringing down your program performance.