
23 Feb
2009
23 Feb
'09
2:02 p.m.
2009/2/23 Esben Mose Hansen
Isn't that admonishing simple wrong in all cases where the the base class is private (and maybe protected, I've never used that)? I mean, when exactly would you risk deleting a class through a pointer or reference to a private base class?
struct Base {}; void Foo(Base* base) { delete base; } struct Derived : private Base { void Bar() { Foo(this); // Oops. } }; Even with private inheritance there is a risk for an object to be deleted through the pointer to base. Although, of course, with public inheritance this risk is much higher. Roman Perepelitsa.