File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -7,4 +7,24 @@ Finds derived class methods that hide a (non-virtual) base class method.
77
88In order to be considered "hiding", methods must have the same signature
99(i.e. the same name, same number of parameters, same parameter types, etc).
10- Only checks public, non-templated methods.
10+ Only checks public, non-templated methods.
11+
12+ The below example is bugprone because consumers of the `Derived ` class will
13+ expect the `reset ` method to do the work of `Base::reset() ` in addition to extra
14+ work required to reset the `Derived ` class. Common fixes include:
15+ - Making the `reset ` method polymorphic
16+ - Re-naming `Derived::reset ` if it's not meant to intersect with `Base::reset `
17+ - Using `using Base::reset ` to change the access specifier
18+
19+ This is also a violation of the Liskov Substitution Principle.
20+
21+ .. code-block :: c++
22+
23+ class Base {
24+ void reset() {/* reset the base class */};
25+ };
26+
27+ class Derived : public Base {
28+ public:
29+ void reset() {/* reset the derived class, but not the base class */};
30+ };
You can’t perform that action at this time.
0 commit comments