📘 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.

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.

सारांश

  • inline replaces the call with the code, good for tiny functions.
  • It is only a hint; the compiler decides.
← Back to C++ Tutorial
🔗

Share this topic with a friend

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

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

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

\n

💻 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ें.