CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.
Get Your Dream Job Now - www.vyoms.com
Sponsored Links
Interview Questions
Our Services

INTERVIEW QUESTIONS C++ FUNCTIONS IN C++ DETAILS
Question :
What do you mean by inline function?
Category Functions in C++ Interview Questions
Rating (4.0) By 81 users
Added on 10/22/2009
Views 12550
Rate it!
Answers:

The idea behind inline functions is to insert the code of a called function at the point where the<br>function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.



Inline functions are like macros in c language. The functions are expanded in the line where it is invoked at the time of compilation. These functions should not include any loops or static members inside it. And also it shouldn?t be a recursive one. Inline functions should return a value .The advantages are to avoid time wastages , stack and registers operations done during function calls and function invokations. Keyword ?inline? should be included in the function definition.<br><br>Example:<br> inline int add(int a,int b)<br> {<br> return a+b;<br> }<br><br> void main()<br> {<br> int x=5;<br> int y=10;<br> cout<<?The sum is : ?<<add(x,y);<br> }<br><br>



Posted by: Anitha

Contact Anitha Contact Anitha

Inline functions are like macros in c language. The functions are expanded in the line where it is invoked at the time of compilation. These functions should not include any loops or static members inside it. And also it shouldn?t be a recursive one. Inline functions should return a value .The advantages are to avoid time wastages , stack and registers operations done in memory during function calls and function invokations. Keyword ?inline? should be included in the function definition.<br><br>Example:<br> inline int add(int a,int b)<br> {<br> return a+b;<br> }<br><br> void main()<br> {<br> int x=5;<br> int y=10;<br> cout<<?The sum is : ?<<add(x,y);<br> }<br>



Posted by: Anitha

Contact Anitha Contact Anitha

inline function is function,the complier insert the entire code where the function is called.<br>inline fuctions reduce the excution time,But it can be used for only smaller functions.<br>



Posted by: uday

Contact uday Contact uday

Inline function is declared to a function so cpp automatically creats its own programme which is unvisible to us.so this function reduces the compile time.but it not suitable for using for loop.Becouse it creats more line prg. than actual prg.



Posted by: ambarish

Contact ambarish Contact ambarish

inline fuctions reduce the excution time,it wont accept long statements



Posted by: umapathi

Contact umapathi Contact umapathi

Inline function makes a program run faster bcoz the overhead of a function call and return is eliminated. This replaced at each point where the function is called.



Posted by: Dilip

Contact Dilip Contact Dilip

inline functions are used to overcome the overhead [the flow of control] of the functions. If a function is defined in the class then by default it acts like an inline function. If a function is defined outside the class, explicitly we need to specify inline keyword. Inline function is very similar to a macro in C



Posted by: sistla laxmi

Contact sistla laxmi Contact sistla laxmi

Inline function are like as macro but they r not macro,when we have to do call a function many times n as our program is small,it takes more execution time,dn for saving the times we use the inline function,it saves our execution times but it doesnot ter approach in large prorame,for using inline function we have to write simply inline before our functon,they have regular wriiten type,<br>e.g<br> inline int sum(int x,int y)<br> {<br> sum=x+y;<br> }<br> void main()<br> int x=2;<br> int y=4;<br>cout<<"
result is:"<<sum(x+y);<br>}<br>



Posted by: poonam yadav

Contact poonam yadav Contact poonam yadav

Inline function to speed up the execution of the program...<br>Syn:<br>inline type fnname()<br>{<br>....<br>....<br>}



Posted by: RajeshKumar

Contact RajeshKumar Contact RajeshKumar

inline function is like macros in c language. It expands code for a called function which reduces execution time and inline function provides type safety which macros don't provide.



Posted by: Anthony

Contact Anthony Contact Anthony

Inline function are just like Macros with some differance<br><br>1. Inline function is a function whereas macros are preprocessive directories.<br><br>2. inline function put request to compiler not command hence if the size of inline functions ihncreases compiler ignore the request & treates the inline function like normal function.



Posted by: Pratibha Bharti

Contact Pratibha Bharti Contact Pratibha Bharti

Inserting inline function is completely depends on the compiler, because we are just request to the compiler to perform inline function. Its depends on the function definition thats why it should be small lines of code. After using this function we are not sure this function will insert or not.



Posted by: T.Ravi Kumar

Contact T.Ravi Kumar Contact T.Ravi Kumar

The function whose code gets inserted, instead of a jump to the function, at the place of call, is called an inline function. Inline functions mayn't work for functions returning values, if a loop or switch or goto exists or if they are recursive.<br><br>Inline functions speed up processing by eliminating the overhead associated with function calls.<br><br>These inline functions help in improving overall performance, but sometimes they make it worse.<br><br>It is a good practice to define functions inline when they are on the critical path of a CPU-bound application. But if the application is network or I/O bound there will be no significant impact.<br><br>



Posted by: Monalisha Nayak

Contact Monalisha Nayak Contact Monalisha Nayak

when a function is called it takes lot of time to executed more no.of instructions so we are using inline function <br> Inline function is a function that is expanded inline when that is invoked.compiler replaces function call to the code



Posted by: pavan kumar

Contact pavan kumar Contact pavan kumar

inline function provides an efficient way for the compiler with the regards of compile time because;it EXPANDS the called function (for example a subfunction being called in the main program)and hence prevents compiler to jump to the location where exactly the function has been DEFINED. Hence by reducing the number of jumps it reduces the overall compile time.



Posted by: prasad

Contact prasad Contact prasad

when a function is invoked so many times, the compiler pushes those function parameters and its code to stack and allocating registers to that... This is better at the level for bigger function....<br> But what about for smaller function(i.e. not containing loops and only few lines)....now a answer arises....s correct.....its waste of time.... <br> C++ avoids this waste of time and resources by providing a greater mechanism called "INLINE FUNCTIONS" .<br> When a function s declared as inline function, the compiler understands that invoked function s so small so it just replaces code instead of pushing parameter into the stack like MACRO.....and then execution begins........



Posted by: Prakash

Contact Prakash Contact Prakash

A common practice is to omit the prototype and to place the entire definition (meaning the function header and all the function code) where the prototype would normally go. The compiler does not have to honor your request to make a function inline. It might decide the function is too large or notice that it calls itself (recursion is not allowed or indeed possible for inline functions), or the feature might not be turned on or implemented for your particular compiler.



Posted by: kumar gourav

Contact kumar gourav Contact kumar gourav

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    Inform me about updated answers to this question

    Related Questions
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Functions in C++ Interview Questions & Answers

    User Options
    Latest 20 Questions
    State the disadvantages of stock dividend for company and for investors.
    State the advantages of stock dividend for issuing company and to the investors.
    State the objects of stock dividend.
    What is stock dividend?
    Define bonus shares.
    What is cash dividend?
    What are property dividends?
    What are bond dividends?
    What is scrip dividends?
    List the forms of dividend.
    Explain in brief the types of stability of dividend or dividend practices.
    What do you mean by stability of dividend?
    State the significance of stability of dividend.
    What are default directories in TYPO3 installation?
    State the determinants of dividend policy?
    What is dividend policy?
    What is mass editing?
    What are the page-related functions in the context menu of a page?
    What is Page tree?
    Explain Backend and Frontend of TYPO3 CMS?



    Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

    MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
    MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

    GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

    IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
    IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

    SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
    SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions



    Cache = 0.003906 Seconds