struct Derived2 : Base2
{ void default1(Base const& x = Intermediate1()) { Base2::default1(x); } // no warning void
default2( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
Base const& x = SimpleDerived())
{
Base2::default2(x);
} void
default3( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
Base x = Base())
{
(Base2::default3(x));
} void
default4( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
E x = (E::E1 | E::E2 | E::E3))
{
Base2::default4(x);
}
};
class Base3
{ public: void f1();
};
class Derived3 : protected Base3
{ public: // effectively changing access from protected to public void f1() { Base3::f1(); }
};
// check the case where the method occurs more than once in a direct path up the class hierarchy struct Base4
{ void f1();
}; struct Derived4_1 : public Base4
{ void f1();
}; struct Derived4_2 : public Derived4_1
{ void
f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
{
Derived4_1::f1();
}
};
struct Base5_1
{ void f1();
}; struct Base5_2
{ void f1();
}; struct Derived5 : public Base5_1, public Base5_2
{ void f1() { Base5_1::f1(); } // no warning expected
};
struct Base6_1
{ bool f1();
}; struct Derived6 : public Base6_1
{ bool
f1() // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
{ bool ret = Base6_1::f1(); return ret;
}
}; /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.