Attempt to add an example (that is as non-controversial as possible) of an inheritance hierarchy to C.120

This commit is contained in:
Louis Brandy 2017-04-17 12:23:22 -07:00
parent f1d3846300
commit 29fdd0d30c

View File

@ -6108,7 +6108,27 @@ Do *not* use inheritance when simply having a data member will do. Usually this
##### Example
??? Good old Shape example?
class DrawableUIElement {
public:
virtual void render() const = 0;
// ...
};
class AbstractButton : public DrawableUIElement {
public:
virtual void onClick() = 0;
// ...
};
class PushButton : public AbstractButton {
virtual void render() const override;
virtual void onClick() override;
// ...
};
class Checkbox : public AbstractButton {
// ...
};
##### Example, bad