Why aren't these shared_ptrs pointing to the same container?
Posted
by BeeBand
on Stack Overflow
See other posts from Stack Overflow
or by BeeBand
Published on 2010-04-04T16:40:04Z
Indexed on
2010/04/04
16:43 UTC
Read the original article
Hit count: 315
I have a class Model:
class Model
{
...
boost::shared_ptr<Deck> _deck;
boost::shared_ptr<CardStack> _stack[22];
};
Deck
inherits from CardStack
.
I tried to make _stack[0]
point to the same thing that _deck
points to by going:
{
_deck = boost::shared_ptr<Deck>(new Deck());
_stack[0] = _deck;
}
It seems that the assignment to _deck
of _stack[0]
results in a copy of _deck
being made. How can I get them to point to the same thing?
© Stack Overflow or respective owner