Inline function(oops)

4,630 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,630
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
63
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Inline function(oops)

  1. 1. Inline function:Inline function is the optimization technique used bythe compilers. It is a function which is declared usinginline keyword or within the class. The function whichis declared within the class is said to be inline functionif it satisfies following conditions:-function should not have any return statements.-function should not be recursive function.-function length should be short.-function should not have any static variable.is considered as inline function by compiler.Inline function can only be requested to compiler, auser can only request to comlier to make a particularfuntion as an inline function, its depend on the compilerto make it as an inline function or not. An inlinefunction is used to short the execution time. Its maintask is that, it copy the body part of an inline functionwhere it is called.Its advantages are as under:
  2. 2. - It shorter the execution time.- It does not require function calling overhead- It saves time.Its disadvantages are as under:- It increases the length of our file.- It may make our file unreadable.e.g:#include<iostream>using namespace std;class number{int n;public:void setdata(){
  3. 3. n=10;}void display(){ Cout<<n;}};In above example, both of the functions will beconsidered as inline function by the compiler as itsatisfies all conditions.

×