vs.

Pure Virtual Function vs. Virtual Function

What's the Difference?

Pure virtual functions and virtual functions are both used in object-oriented programming to achieve polymorphism, but they have some key differences. A virtual function is a function that is declared in a base class and can be overridden in derived classes. It allows the derived class to provide its own implementation of the function. On the other hand, a pure virtual function is a virtual function that is declared in a base class but has no implementation. It serves as a placeholder for derived classes to provide their own implementation. A class containing a pure virtual function is called an abstract class and cannot be instantiated. Derived classes must override the pure virtual function to become concrete classes. In summary, while virtual functions provide a default implementation that can be overridden, pure virtual functions act as placeholders that must be overridden in derived classes.

Comparison

Loading...

Further Detail

Loading...

Comparisons may contain inaccurate information about people, places, or facts. Please report any issues.