Differences between the inline function and the normal function in C++17 Mar 2025 | 4 min read The function is a block of reusable code that performs a particular task. It is defined and called for from different sections of the program. In C++, the functions are divided into many types based on their usage and features. These are Regular functions, Inline functions, Recursive functions, Friend functions, Virtual functions, Lambda functions, etc. These functions are essential for organizing and structuring the code and making the entire program maintainable. Normal function:Regular or normal functions are the most common functions in C++. They are defined outside of any class and have a separate block of code called when the function is invoked. When the normal function is called, the compiler creates a new stack frame for the functions to track the function calls. This function has a return type. It will return some value after doing computation. It takes some values whenever it is called. Those values are generally called arguments. The function will work on those arguments and return the output. There will be no return type for some normal functions, which means those have a void return type. Syntax of the Normal Function:It has the following syntax: The return type specifies the type of the value the function returns. Parameters are input to the function, which are always present in parentheses. The function code is written in {}. The return is used to give output to the function, which is called. Example:Let us take a C++ program to illustrate the normal functions: Output: ![]() Inline function:Inline functions are special types of functions in C++. Which are small, frequently used code snippets. These are directly inserted into the code at the point where they are called are called inline functions. The compiler will replace the function call with the actual code at the call site for performance optimization. So here, the new stack frame is not created for the function or jumps to a separate block of code. It will help to improve the performance. Syntax of the Inline function:It has the following syntax: The keyword "inline" is used to use the inline function. The return type is not mandatory. Parameters are input values of the function. Example:Let us take a C++ program to illustrate the inline functions: Output: ![]() Similarities between the inline function and normal function:There are several similarities between the inline and normal functions. Some main similarities between the inline and normal functions are as follows:
Differences between the inline functions and normal functions:![]() There are several differences between the inline and normal functions. Some main differences between the inline and normal functions are as follows:
Next TopicEdmonds Karp Algorithm in C++ |
Introduction: The default method of interacting with strings in C++ is called std::string since it provides users with a wide range of useful functionalities. Among many other string operations, std::string offers string operations, including looking for substrings, comparing strings, concatenating strings, and slicing strings. But each time...
5 min read
Addressing local variable retrieval of different functions in C++ is important and is the heart of the program's variable scope, function call, and data sharing. In C++, local variables can be declared only within a specific block of code, usually in the body of a particular...
8 min read
In this article, we will discuss the weak pointer in C++ with their syntax and examples. The C++ weak_ptr is a standard library component. It is used to store weak references to any objects controlled by the shared_ptr standard library pointer, which is used to ultimately transform...
6 min read
A mathematical procedure known as a factorial that determines the product of all positive integers from 1 to a specified number "n". In this article, you will see how to find factorial of a number using iteration in C++. Understanding Factorial: The product of all positive numbers less...
2 min read
C++ has a set of rules for naming variables, functions, and other identifiers in your code. These rules, known as naming conventions, help to make your code more readable and maintainable. Guidelines for Variable names should be descriptive and meaningful. For example, a variable that holds the...
9 min read
A key idea in object-oriented programming called containership enables the construction of sophisticated data structures out of simpler ones. Containership is essentially the practice of putting one object inside another. It is made possible by making use of object pointers that enable the development of intricate...
4 min read
C++ is among the most widely used and efficient object-oriented programming languages, and it's the perfect language to begin with in order to accomplish low-level tasks. C++ applications can be found in a variety of disciplines, including embedded programming, web servers, gaming, and even increased trading applications....
8 min read
In this article, you will learn about the thread_local in C++ with its syntax and examples. What is the thread_local? The thread_local keyword allows you to declare variables with thread-local storage duration. It means that each thread accessing the variable will get its copy of that variable. Syntax: It has...
5 min read
In this article, we will discuss a C++ program to check if a matrix is orthogonal or Not with its output. But before going to the program, we must know about the orthogonal. The orthogonal matrix is one in which the transpose of the original matrix and...
4 min read
In C++, a top-down approach is a programming methodology that involves starting with an overview of the problem, breaking it down into smaller sub-problems, and then gradually building the solution by implementing each sub-problem in a hierarchical manner. This approach is also known as the "dividing...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India