Skip to content

Commit 30ca722

Browse files
author
Tom James
committed
Fix docs
1 parent c5e31e3 commit 30ca722

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

clang-tools-extra/docs/clang-tidy/checks/bugprone/method-hiding.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,21 @@ In 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).
1010
Only checks public, non-templated methods.
1111

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
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
1818

1919
This is also a violation of the Liskov Substitution Principle.
2020

2121
.. code-block:: c++
2222

23-
class Base {
23+
struct Base {
2424
void reset() {/* reset the base class */};
2525
};
2626
27-
class Derived : public Base {
28-
public:
27+
struct Derived : public Base {
2928
void reset() {/* reset the derived class, but not the base class */};
3029
};

0 commit comments

Comments
 (0)