inheritance

class NmapScanner final : public Scanner {
public:
    NmapScanner() : Scanner("nmap") {}
    std::string describe() const override { return name_ + " ready"; }
};

That compiled and ran

virtual

A virtual function dispatches through the base pointer The base destructor must be virtual when the class is meant to be deleted polymorphically Forgetting it is undefined behavior

override

Write override It lets the compiler catch a signature that does not match Without it a typo silently creates a new function and the base version keeps running

final

final on a class stops inheritance final on a virtual function stops further overriding Use it when the design does not allow extension

Prefer composition

Inheritance is a tool, not the default answer When one class merely uses another, store it as a member Deeper hierarchies are harder to change later

Next

RAII in 07 RAII

Posted