|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> class PrivateClass;
> class MyClass
> {
> std::shared_ptr<PrivateClass> privateObject;
> };
Oh, and take into account that if instances of MyClass are copied around,
the copies will share the one and same PrivateClass object. That will not
get deep-copied. (That's what the "shared ptr" means, actually.)
If you want to avoid MyClass being copied around, that can be disabled.
(Of course this restricts the ways in which the class can be used, so
it's always a compromise.)
Another possibility is to write a copy constructor and a copy assignment
operator that deep-copies the private object... It all depends on how
exactly you need MyClass to behave.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |