📘 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

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.

Inline Function क्या है?

💡 Note

Inline function compiler से कहता है कि function call को सीधे function code से replace करे — छोटी functions के लिए call overhead बचाता है।

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

Note

💡 Note

inline सिर्फ एक request है। बड़ी functions के लिए compiler इसे ignore कर सकता है।

सारांश

  • inline call को code से replace करता है, छोटी functions के लिए अच्छा।
  • यह सिर्फ hint है; compiler तय करता है।
← Back to C++ Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n