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 is using namespace std in cpp?

794


Is c++ primer good for beginners?

825


How did c++ start?

868


What does I ++ mean in c++?

816


What data encapsulation is in c++?

812


Can a class be static in c++?

852


What are pointers used for c++?

835


What is algorithm in c++ programming?

826


Explain what is oop?

856


What is vectorial capacity?

968


How to defines the function in c++?

862


Difference between declaration and definition of a variable.

928


What is a local reference?

954


What are the types of container classes?

849


What is the advantage of an external iterator.

807