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

Give 10 points of differences between C & C++.

627


How do you save a c++ program?

559


What is #include cmath?

665


How many standards of c++ are there?

628


What is an inclusion guard?

622






How would you use qsort() function to sort an array of structures?

726


Why is it necessary to use a reference in the argument to the copy constructor?

637


How to demonstrate the use of a variable?

644


Why do we use constructor?

605


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

2073


In a function declaration what does extern means?

600


What programming language should I learn first?

594


Is c++ vector a linked list?

552


Write about the various sections of the executable image?

574


What do you mean by overhead in c++?

583