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

List the issue that the auto_ptr object handles?

821


Explain the difference between c & c++?

816


What is meant by the term name mangling in c++?

729


Discuss the possibilities related to the termination of a program before entering the mainq method?

747


What is pointer -to-members in C++? Give their syntax?

797


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

833


What is a class definition?

815


What is the difference between set and map in c++?

894


Array base access faster or pointer base access is faster?

2051


What is DlgProc?

785


Explain the problem with overriding functions

845


Why should you learn c++?

805


What does scope resolution operator do?

814


What are the stages in the development cycle?

793


What are proxy objects in c++?

902