---
title: "Inline Function in C++"  
description: "In this blog, I’m explaining about Inline function in C++  What is Inline function?C++ provides an inline functions to reduce the function call overhe"  
author: "priyanka kushwaha"  
published: 2015-02-05  
updated: 2015-02-05  
canonical: https://www.mindstick.com/blog/758/inline-function-in-c-plus-plus  
category: ".net"  
tags: ["visual c++"]  
reading_time: 1 minute  

---

# Inline Function in C++

In this blog, I’m explaining about [Inline function](https://www.mindstick.com/interview/2269/what-do-you-mean-by-inline-function) in [C++](https://www.mindstick.com/blog/745/array-in-c-plus-plus)\

##### What is Inline function?

C++ provides an inline [functions](https://www.mindstick.com/forum/160140/explain-the-role-of-functions-as-a-service-faas-in-serverless-computing) to reduce the function call overhead. Inline function is a function that is expanded in line when it is called. When the inline function is called whole code of the inline function gets inserted at the point of inline function call. This substitution is performed by the c++ [compiler](https://www.mindstick.com/articles/27/just-in-time-compiler) at [compile](https://www.mindstick.com/forum/2316/how-to-views-compile-in-mvc) time. Inline function may [increase](https://www.mindstick.com/articles/12959/are-you-struggling-to-increase-the-profit-of-your-liquor-store) [efficiency](https://www.mindstick.com/articles/13091/12-tips-to-boost-your-studying-efficiency) if it is small.

##### Example:

```
#include "stdafx.h"#include <iostream>using namespace std;using namespace System;inline double Max(double x,double y); public class InLineClass{public:            double Max(double x,double y){            return(x>y)?x:y;} int Max(int x,int y)            {            return(x>y)?x:y;} };  public class DriveClass:InLineClass{public:              };// Main function  for the programint main(array<System::String ^> ^args){            DriveClass DriveRef;             InLineClass BaseRef            double firstNum,SecNum,result;            cout<<"Enter a number";            cin>>firstNum;            cout<<"Enter another number";            cin>>SecNum;            if(firstNum==SecNum)            {                        result=firstNum;                        cout<<"Equal No.=";            }            else            {                        result= DriveRef.Max(firstNum,SecNum);// error                        result= BaseRef.Max(firstNum,SecNum);//Right            cout<<"Greater No.=";             }                        cout<<result;            Console::ReadKey();            return 0;}
```

Note: Inline function cannot inherit in Drive [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp).

---

Original Source: https://www.mindstick.com/blog/758/inline-function-in-c-plus-plus

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
