Difference between virtual function and inline function in C++ Last Updated : 18 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Virtual function: Virtual function is a member function which is declared within a base class and is redefined by a derived class. Inline function: Inline function is a normal function which is defined by the keyword inline, it is a short function which is expanded by the compiler and its arguments are evaluated only once. The syntax of defining the function inline in C++ is: inline return-type function-name(parameters) { // function code } Difference between virtual function and inline function are as follows: Virtual function Inline function 1. Virtual function must be declared in public section of class.1. Inline function is a normal function which is defined by the keyword inline.2. Virtual function cannot be static.2. Inline function can also be non-static.3. Virtual function is defined in base class.3. Inline function are the short length functions that are automatically made the inline functions without using the inline keyword inside the class.4. Virtual function are used to decrease the efficiency of code.4. Inline function are used to increase the efficiency of code.5. Virtual function is to run time polymorphism.5. Inline function is to compile time polymorphism.6. Virtual function may consists of virtual destructor but it cannot have a virtual constructor. 6. Inline function can also consist of inline constructor.7. Virtual may use for dynamic linkage.7. Inline function is used to reduce the function call overhead. Comment More infoAdvertise with us Next Article Difference between virtual function and inline function in C++ A anuragtarang60 Follow Improve Article Tags : Difference Between C++ C++-Virtual Functions Practice Tags : CPP Similar Reads Difference between Virtual function and Pure virtual function in C++ Virtual Function in C++ A virtual function is a member function which is declared within a base class and is re-defined(Overridden) by a derived class. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execu 2 min read Difference Between Friend Function and Virtual Function in C++ A friend class can access private and protected members of other classes in which it is declared as friend. It is sometimes useful to allow a particular class to access private members of other classes. Just likely, a friend function is a function that is declared outside the scope of a class. This 3 min read Difference Between Inline and Normal Function in C++ Inline Function is a function that is expanded inline by the compiler when it is invoked. During function call, a lot of overhead tasks are performed like saving registers, pushing arguments to the stack, and returning to the calling function. These overheads are time-consuming and inefficient for s 4 min read C++ - Difference Between Functors and Functions In C++, we have multiple options to operate over the data like in the case where we can use functions and functors. Although both seem to be similar in a few ways but have multiple differences between them. Let's check the differences between functions and functors in C++. What are functions? Functi 3 min read Difference between Static and Friend Function in C++ Static Function: It is basically a member function that can be called even when the object of the class is not initialized. These functions are associated with any object and are used to maintain a single copy of the class member function across different objects of the class. This function is denot 3 min read Like