Difference between Virtual function and Pure virtual function in C++ Last Updated : 16 Jan, 2025 Comments Improve Suggest changes Like Article Like Report 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 execute the derived class’s version of the function. Pure Virtual Functions in C++ A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have an implementation, we only declare it. A pure virtual function is declared by assigning 0 in the declaration. Similarities between virtual function and pure virtual functionThese are the concepts of Run-time polymorphism. Prototype i.e. Declaration of both the functions remains the same throughout the program. These functions can't be global or static.Difference between virtual function and pure virtual function in C++Virtual functionPure virtual functionA virtual function is a member function of base class which can be redefined by derived class.A pure virtual function is a member function of base class whose only declaration is provided in base class and should be defined in derived class otherwise derived class also becomes abstract.Classes having virtual functions are not abstract.Base class containing pure virtual function becomes abstract.Syntax: virtual<func_type><func_name>() { // code}Syntax: virtual<func_type><func_name>() = 0;Definition is given in base class.No definition is given in base class.Base class having virtual function can be instantiated i.e. its object can be made.Base class having pure virtual function becomes abstract i.e. it cannot be instantiated.If derived class does not redefine virtual function of the base class, then it does not affect compilation.If derived class does not redefine virtual function of the base class, then no compilation error is encountered, but like the base class, derived class also becomes abstract. Comment More infoAdvertise with us Next Article Difference between Virtual function and Pure virtual function in C++ 4srashti Follow Improve Article Tags : Technical Scripter Difference Between C++ Technical Scripter 2019 cpp-virtual C++-Virtual Functions Virtual Functions +3 More Practice Tags : CPP Similar Reads Difference between virtual function and inline function in C++ 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 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 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 Difference between user defined function and library function in C/C++ Library Functions These functions are the built-in functions i.e., they are predefined in the library of the C. These are used to perform the most common operations like calculations, updation, etc. Some of the library functions are printf, scanf, sqrt, etc. To use these functions in the program the 3 min read Like