|
Boost Users : |
From: Richard Damon (Richard_at_[hidden])
Date: 2007-05-02 07:18:34
One comment is that:
Class A {
}; // No virtual destructor
Class B : public A {
}
shared_ptr<A>(new B)
Should cause UB as the shared pointer will will eventually call delete on
its parameter, and since A has no virtual destructor and is NOT the type the
object was created with, you get UB.
It basically boils down to the equivalent to this
A* ptr = new B;
delete ptr;
which is a no-no.
A NEEDS to have a virtual destructor to use it the way you are.
Richard
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