|
Boost Users : |
Subject: Re: [Boost-users] How to use noncopyable?
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-02-23 09:02:28
2009/2/23 Esben Mose Hansen <boost_at_[hidden]>
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net