📘 Lesson · Lesson 67
Inline Functions
Inline Functions
What is an Inline Function?
💡 Note
An inline function asks the compiler to replace the function call with the function code directly — saving call overhead for small functions.
Example
C++
#include <iostream>
using namespace std;
inline int square(int x) { return x * x; }
int main() {
cout << square(5); // 25
return 0;
}Output:
25
25
Note
💡 Note
inline is only a request. The compiler may ignore it for large functions.
Summary
- inline replaces the call with the code, good for tiny functions.
- It is only a hint; the compiler decides.
an Inline Function क्या है?
💡 Note
An inline function asks the compiler to replace the function call with the function code directly — saving call overhead for small functions.
Example
C++
#include <iostream>
using namespace std;
inline int square(int x) { return x * x; }
int main() {
cout << square(5); // 25
return 0;
}Output:
25
25
Note
💡 Note
inline is only a request. The compiler may ignore it for large functions.
सारांश
- inline replaces the call with the code, good for tiny functions.
- It is only a hint; the compiler decides.
💻 Live Code Editor
Is page ke program yahan ready hain — chalाएं, badlें aur seekhें. Bina kuch install kiye.
Powered by OneCompiler. Editor mein code apne aap aa jata hai — Run dabaakर output dekhें.
Agar load na ho to naye tab mein kholें.