📘 Lesson · Lesson 67
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.
💻 लाइव कोड एडिटर
इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.