Inline function in C++

2,235 views 8 slides Oct 27, 2015
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

How to write inline function in C++


Slide Content

Inline Functions Yogendra Pal

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 | [email protected]

Function call in detail www.learnbywatch.com | [email protected]

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 | [email protected]

Inline function creation Preface the function declaration with the keyword inline , OR Preface the function definition with the keyword inline . www.learnbywatch.com | [email protected] inline return_type function_name ( argument_list ); inline return_type function_name ( argument_list ) { statements; } OR

Inline Function at Run Time www.learnbywatch.com | [email protected] inline void function_name ( argument_list ) { statement_1; statement_2; } i nt main() { function_name (); cout << “new line”; function_name (); } i nt main() { statement_1; statement_2; cout << “new line”; statement_1; statement_2; } At run time

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 | [email protected]

Ask your questions to learn better Yogendra Pal www.learnbywatch.com | [email protected]