|
Boost Users : |
Subject: [Boost-users] [shared pointer] - question about different types pointing to the same object
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-06-06 19:12:52
I've looked through the shared_ptr documentation and am still puzzled about
something.
suppose I have
class base1 {
virtual ~base1;
...
};
class derived1 : public base1
{
....
};
shared_ptr<derived1> pd1(new derived1)
shared_ptr<base1> pb1(pd);
? do pd1 and pb1 refer to the same object?
class base2 {
virtual ~base2;
...
};
class derived3 : public base1, public base2 {
...
};
shared_ptr<base2> pb2(pd1);
? do pb1 and pb2 refer to the same object?
I'm presuming they do, but it's not really clear to me that
this would work. To check this I could downcast everything to derived3.
BUT when I have pb1 and pb2, I don't know what to downcast to. since
there could be
class derived4 : public base1, public base2 {
...
};
So how could I verify whether an arbitrary pb1 and pb2 point to the
same object or not?
Robert Ramey
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