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

whats the size of class EXP on 32 bit processor? class EXP { char c1; char c2; int i1; int i2; char *ptr; static int mem; };

5 Answers   Huawei,


What is diamond problem in c++?

0 Answers  


What are the static members and static member functions?

1 Answers  


What C++ libraries are you proficient with?

1 Answers   Google,


What are the advantages of using a pointer? Define the operators that can be used with a pointer.

0 Answers  






What and all can a compiler provides by default?

3 Answers   Accenture, HP,


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

0 Answers  


If I is an integer variable, which is faster ++i or i++?

0 Answers  


write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)

0 Answers  


When you overload member functions, in what ways must they differ?

0 Answers  


Why is c++ still popular?

0 Answers  


When can you tell that a memory leak will occur?

1 Answers  


Categories