What are the advantages of having a definition of pure virtual method In C++? [duplicate]

  abstract-class, c++

Although pure virtual methods typically have no implementation in the class that declares them, pure virtual methods in some languages (e.g. C++ and Python) are permitted to contain an implementation in their declaring class. What are the benefits of doing so, since C++ allows this behavior?

class Abstract
{
    public:
    virtual void show() = 0;
};

void Abstract::show() { print("Default Implementation"); }

class Derived : public Abstract
{
    public:
    void show() override { print("Overridden Implementation"); }
};

Source: Windows Questions C++

LEAVE A COMMENT