What are inline functions?

Answers were Sorted based on User's Feedback



What are inline functions?..

Answer / roshanpr

Functions that are expanded inline ( that we during there
call) is called inline functions.

Usually when there there is a function call the control is
taken to the function definition where the code is executed
and then the control returns back to main. But in case of
inline function there is no jump in the flow, rather the
function it self is expanded at the place of call.

You can make function inline in two ways.

1) Prefixing keyword "inline" durin the function
declaration.
2) By defining the function inside the class declaration

Ex: shows both the implementation

Class myClass
{

int age;

public:
inline void getAge();
void showAge()
{
cout<<"Age:"<<age;
}
};

void myClass getAge()
{
cout<<"Age:"<<age;
}

Is This Answer Correct ?    11 Yes 1 No

What are inline functions?..

Answer / laxman

Inline function :-

In genereal function call branching method is there . In
inline function substitution takes place . Inline
functions are expanded during compilation . Exectution
becomes fast and branching is eliminated. Inline word is a
request but not command. If inline is not possible compiler
takes it like a genral function call.
rules:
1 function should be small
2. Controll statements are not valid like for ,while


if u need more mail to me

Is This Answer Correct ?    6 Yes 2 No

What are inline functions?..

Answer / nashiinformaticssolutions

Functions expanded at the point of call, avoiding function call overhead.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Adobe Interview & Adobe Placement Paper

1 Answers   Adobe,


Write a program in C++ for Fibonacci series

0 Answers   Axtria, ITC Indian Tobacco Company,


Why is c++ is better than c?

0 Answers  


Define linked lists with the help of an example.

0 Answers  


Explain the advantages of using friend classes.

0 Answers  






What do you mean by inheritance in c++? Explain its types.

0 Answers  


Memory is not a constraint. In a single iteration(NOTE: you can't go back), how will you find out the 10th last node/item in a linked list.

16 Answers   BNB, FDS, Goldman Sachs, Nagarro,


Define a constructor - what it is and how it might be called (2 methods)?

0 Answers  


Which is best ide for c++?

0 Answers  


Can a program run without main in c++?

0 Answers  


why is iostream::eof inside a loop condition considered wrong?

0 Answers  


What is the most common mistake on c++ and oo projects?

0 Answers  


Categories