What are inline functions?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are enumerations?

651


How would you implement a substr() function that extracts a sub string from a given string?

561


In a function declaration what does extern means?

591


What is an inline function in c++?

625


Write about the retrieval of n number of objects during the process of delete[]p?

567






How would perform Pattern Matching in C++?

650


What is purpose of abstract class?

582


What is ostream in c++?

567


Is c++ still being used?

561


What do you mean by inheritance in c++?

597


When does a 'this' pointer get created?

614


What is rvalue?

673


Explain stack unwinding.

630


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

599


what is a class? Explain with an example.

615