IT Community - Software Programming, Web Development and Technical Support

Inline Function C++

This is a discussion on Inline Function C++ within the C and C++ Programming forums, part of the Software Development category; may i know the advantages of inline functions...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-26-2007, 10:44 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Inline Function C++

may i know the advantages of inline functions
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-26-2007, 10:47 PM
Anandavinayagam Anandavinayagam is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 131
Anandavinayagam is on a distinguished road
Default Re: Inline Function C++

Inline functions are functions where the call is made to inline functions. The actual code then gets placed in the calling program

Inline is that you can sometimes speed up your program by inlining the right function. Instead of calling the function every time it is invoked, the compiler will replace the function call with a copy of the function body. If it's a small function which gets called a lot, this can sometimes speed things up.
__________________
The MOSS
Master of Solution Service
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-27-2007, 04:17 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Post Re: Inline Function C++

Inline function are exactly similar to macros in c.

By making a function inline we just make a request to the compiler to treat the function as inline. the compiler may reject the request for several reasons for instance if we use loop || control structures such as switch-case it will be treated as normal function.

As the name says it is a function defined in "a line" we can extend the length of the program upto 4-6 lines.

The only difference between the Macros & inline function is, inline function have more control over the arguments/parameters passed to it.
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-27-2007, 10:15 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: Inline Function C++

Total number of Lines for inline function should be less...not more than 10....
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-28-2007, 02:02 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Post Re: Inline Function C++

Hi

i think length(no. of lines) of the inline function depends on the compiler. as the length grows, it looses the percent of possibilities for being inline. we cannot say it is exactly less that 10 lines.
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-28-2007, 03:36 AM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Re: Inline Function C++

hi,

can any one give example for Inline function?..
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-02-2008, 02:40 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Post Re: Inline Function C++

hi
Quote:
inline void drawLine(int count,char symbol){
cout.width(count);
cout.fill(symbol);
cout<<""<<endl;
}
inline void coutHeadingAt(char *title,int length){
cout<<setw(length)<<right<<title;
}
void main(){
starLine(30,'*');
coitHeadingAt("Inline",30);
starLine(25,'~');
cout<<"cube (3) = "<<cube(3);
starLine(30,"=");
}
inline int cube(int x){
return x*x*x;
}
output
~~~~
Quote:
******************************
Inline
~~~~~~~~~~~~~~~~~~~~~~~~~
cube(3) = 27
==============================
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-02-2008, 02:42 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Talking Re: Inline Function C++

Hi,
In the last example i just made a mistake, just change as drawLine() instead of starLine () in the main function..
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-25-2008, 02:53 AM
shikha shikha is offline
D-Web Trainee
 
Join Date: Nov 2008
Posts: 3
shikha is on a distinguished road
Default Re: Inline Function C++

Hello friends

Thanks for sharing so much of information..Bt please also define the inline function by giving example of program...

Thanks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the use of ob_start() function? saravanan PHP Programming 3 03-28-2008 02:57 AM
Inline javascript Tips & Tricks Sabari HTML, CSS and Javascript Coding Techniques 9 12-18-2007 06:14 AM
reload function simplesabita Testing Tools 1 08-22-2007 03:45 AM
What are inline functions? prasath C and C++ Programming 3 07-20-2007 06:28 AM
Diff inline function and ordinary function vigneshgets C and C++ Programming 1 05-24-2007 11:34 AM


All times are GMT -7. The time now is 10:14 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0