Sponsored Links

Interview Questions
Recommended Books












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 12574
Rate it!

Highly Recommended, Hand Picked Functions in C++ Books



Question :

What do you mean by inline function?


Answer:

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.
Source: CoolInterview.com



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>
Source: CoolInterview.com



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>
Source: CoolInterview.com



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>
Source: CoolInterview.com



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.
Source: CoolInterview.com



Posted by: ambarish

Contact ambarish Contact ambarish

inline fuctions reduce the excution time,it wont accept long statements
Source: CoolInterview.com



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.
Source: CoolInterview.com



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
Source: CoolInterview.com



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>
Source: CoolInterview.com



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>}
Source: CoolInterview.com



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.
Source: CoolInterview.com



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.
Source: CoolInterview.com



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.
Source: CoolInterview.com



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>
Source: CoolInterview.com



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
Source: CoolInterview.com



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.
Source: CoolInterview.com



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........
Source: CoolInterview.com



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.
Source: CoolInterview.com



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
India News Network

Latest 20 Questions
What are the Hadoop related Projects at Apache?
What are the modules included in Apache Hadoop Project?
What is Apache Hadoop?
What is a Private Cloud? Do we need one to handle Big Data?
How Can We Cope with the Impact of Big Data?
What skills do Big Data analysts need to have?
What does a Big Data analyst do?
What are some real-world examples of Big Data and how it is used?
What is Big Data Analytics?
Why Big Data is becoming so important?
What is the impact of Big Data on Sports Industry?
What is the impact of Big Data on Real estate Industry?
What is the impact of Big Data on Retail Banking Industry?
What is the impact of Big Data on Retail Industry?
What is the impact of Big Data on Technology Industry?
What is the impact of Big Data on Information Technology Industry?
What is the impact of Big Data on Internet of Things (IoT) Industry?
What is the impact of Big Data on Media Industry?
What is the impact of Big Data on Education Industry?
What is the impact of Big Data on Healthcare Industry?



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.009766 Seconds