Inline Functions in C++

Article by: Manish Methani

Last Updated: October 17, 2021 at 10:04am IST
3 min 42 sec read

What are Inline Functions ?

To clean up the code we write functions outside the class and this is best way to write any object oriented code. So why Inline Function ?. When we declare any function as inline then while compilation, compiler will replace that call of a function with the exact code whic you had written outside of that class.

In this example , compiler will replace the statement ,

inline void display();

with

void Game :: display()
{
  cout<

Benefit of this inline function is to increase the execution speed of a program . By writing inline it skips the step of function call which actually takes overhead in memory and replaces that line with actual code. So in this way code looks cleaned plus memory saving :)

#include 
using namespace std;
class Game
{
public:
  int abc;

Game()
{
  abc = 5;
}
inline void display();
}; 

void Game :: display()
{
  cout<

Output :-

5

Learn to Build 5 Apps Without Coding using FlutterFlow

  • Lifetime access to all the 5 FlutterFlow Courses
  • Complete FlutterFlow training
  • All future course updates
  • Access via Codzify mobile app
  • 24h 42m of Learning Content
  • 5 FlutterFlow at Codzify just ₹1500 ($17.44)
  • Access to Dating App Course, Grocery App Course, Courses App Course, FlutterFlow AI Agents Course, Doctor Appointment Booking Supabase Course.
  • Clone Ready-Made Courses App instantly in FlutterFlow.
  • 30-Day 100% Money-Back Guarantee.

Learn More
Codzify Logo

Terms and Conditions    Cookie Policy   Refund Policy   Adsense Disclaimer

Contact: [email protected]