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 binary search in c++?

570


What is the difference between prefix and postfix versions of operator++()?

598


What is vector pair in c++?

716


Is it possible for a member function to delete the pointer, named this?

617


Is java a c++?

568






Can I learn c++ in a week?

585


Is c++ a float?

607


When does a name clash occur in c++?

720


Explain the concept of dynamic allocation of memory?

619


Why do we need templates?

542


What are the general quetions are in DEna bank manager IT/System interviews?

1538


What is the benefit of learning c++?

555


How to allocate memory dynamically for a reference?

546


Which is the best c++ compiler?

598


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

525