2. At the end of this tutorial you will be able to
• Explain how does function call happens in computer memory.
• Explain inline function.
• Explain the difference between inline function and regular function.
• Identify inline functions from a given c++ program.
• Write inline functions in c++ program.
• Explain when a function qualify for inline function.
www.learnbywatch.com | yogendra@learnbywatch.com
3. Function call in detail
www.learnbywatch.com | yogendra@learnbywatch.com
4. Inline Function
• Call to an inline function is replaced by the function code.
• Run faster than regular functions.
• Consume more memory than regular functions.
www.learnbywatch.com | yogendra@learnbywatch.com
5. Inline function creation
• Preface the function declaration with the keyword inline, OR
• Preface the function definition with the keyword inline.
www.learnbywatch.com | yogendra@learnbywatch.com
inline return_type function_name(argument_list);
inline return_type function_name(argument_list)
{
statements;
}
OR
6. Inline Function at Run Time
www.learnbywatch.com | yogendra@learnbywatch.com
inline void function_name(argument_list)
{
statement_1;
statement_2;
}
int main()
{
function_name();
cout << “new line”;
function_name();
}
int main()
{
statement_1;
statement_2;
cout << “new line”;
statement_1;
statement_2;
}
At run time
7. Inline function in Class
• Write function definition inside class declaration to make it inline.
• Make a function inline using inline keyword outside class declaration.
www.learnbywatch.com | yogendra@learnbywatch.com
8. Ask your questions
to learn better
Yogendra Pal
www.learnbywatch.com | yogendra@learnbywatch.com