diff --git a/rules/S1006/cfamily/rule.adoc b/rules/S1006/cfamily/rule.adoc index 750ba81449b..1bbd84436bc 100644 --- a/rules/S1006/cfamily/rule.adoc +++ b/rules/S1006/cfamily/rule.adoc @@ -4,26 +4,27 @@ Overriding the default parameter value inherited from a parent class will lead t === Noncompliant code example -[source,cpp] +[source,cpp,diff-id=1,diff-type=noncompliant] ---- -enum E_ShapeColor {E_RED, E_GREEN, E_BLUE}; +enum E_ShapeColor {E_RED, E_GREEN, E_BLUE}; class Shape -{ +{ public: - virtual void draw(E_ShapeColor color = E_RED) const + virtual void draw(E_ShapeColor color = E_RED) const { ... } }; -class Rectangle : public Shape + +class Rectangle : public Shape { public: - virtual void draw(E_ShapeColor color = E_BLUE) const override // Non-compliant + virtual void draw(E_ShapeColor color = E_BLUE) const override // Noncompliant { - ... + ... } -}; +}; int main() { Shape *shape = new Rectangle{}; @@ -33,28 +34,28 @@ int main() { === Compliant solution -[source,cpp] +[source,cpp,diff-id=1,diff-type=compliant] ---- -enum E_ShapeColor {E_RED, E_GREEN, E_BLUE}; +enum E_ShapeColor {E_RED, E_GREEN, E_BLUE}; class Shape -{ +{ public: - virtual void draw(E_ShapeColor color = E_RED) const + virtual void draw(E_ShapeColor color = E_RED) const { ... } }; -class Rectangle : public Shape +class Rectangle : public Shape { public: virtual void draw(E_ShapeColor color) const override // OR: virtual void draw(E_ShapeColor color = E_RED) const override { - ... + ... } -}; +}; int main() { Shape *shape = new Rectangle{};