Inline Functions | Introduction to Programming with C++ | Part 41

preview_player
Показать описание
If a function is inline, the compiler places a copy of the specified function’s code at each point where the function is called at compile time.
To reduce the overhead of control transfer we tend to use inline functions.
Without inline functions the compiler will have to move back and forth, thus creating more control transfers. The lesser the control transfers, the faster the speed of the compilation.
Syntax:

Inline return-type function-name(parameters){
//function-code
}

Plugins🔌
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

SUBSCRIBE🔔
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Relevancy dies in a heartbeat, and I would love to sustain this channel in the long run. Every subscriber counts and it really means the world if you were one of them. So please SUBSCRIBE to my CHANNEL.

Most Engrossing Videos🎬
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

Gear⚙️
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Laptop: HP Spectre 13
Microphone: PC Mic

Mentions👥
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

#InlineFunctions
Рекомендации по теме
Комментарии
Автор

There seems to be a slight mistake at 0:40. I meant to say runtime speed instead of saying compilation speed. Inline Functions help enhance the runtime speed (the time it takes your program to run). Thank you @Peterolen for pointing it out.
Furthermore, I would like to thank every one of my subscribers! It truly means the world🌎🙌 I will continue providing you with quality content🎊. All I need from you is your support by sharing my videos with others.💗
Let's keep on coding!

CodingCleverly
Автор

The inline keyword is related to ODR (One Definition Rule). When you do not write this keyword, the compiler can still perform inline expansion optimization. It may not do it when you write either. If that were the case this keyword would be ridiculous.

serhatarslan
Автор

good video man, i understand thanks to you 👍

kwieli
Автор

Why does not compiler put inline everywhere automatically?

bohdan_tyshchenko
Автор

NOTE:
You can define a function inline using the inline keyword, which may or may not improve execution speed.

CodingCleverly
Автор

You make it so understandable. Thank u!

dhanveersolanki
Автор

so, does in your case if you did

cout << triple(5);

inline would basically do the equivalent of doing

cout << (5*3);

?

sebby