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

Post New Answer

More C++ General Interview Questions

What is c++ 11 and c++ 14?

0 Answers  


what is Loop function? What are different types of Loops?

0 Answers  


What are templates? where we should use it?

2 Answers   Alcatel,


Is vector a class in c++?

0 Answers  


How to declare a pointer to an array of integers?

0 Answers  






How many types of casting are there in C++? When is a dynamic cast,static_cast,reinterpret cast used?

2 Answers   CTS,


Explain how would you handle a situation where you cannot call the destructor of a local explicitly?

0 Answers  


What is a pdb file?

0 Answers  


What does new in c++ do?

0 Answers  


Do class method definitions?

0 Answers  


How can you force instantiation of a template?

1 Answers   ABC, Amazon,


How many different levels of pointers are there?

0 Answers   Genpact,


Categories