Relative Content

Tag Archive for c++shared-ptr

passing a shared_ptr to a function from another function

I’m returning to C++ after a long time, having inherited a code-base, a part of which has the structure in the following code. I have two objects, Wrapped and Wrapper and as might be expected, Wrapper wraps Wrapped. There are two factory methods make_Wrapper and make_Wrapped which return pointers to corresponding objects.

Clarifying some questions about `std::shared_ptr`

I have a class Box, and assume that it is rather heavy weight (eg. memory intensive + dynamically allocated data). I have another class BoxWrapper, which as the name suggests is essentially a wrapper on top of Box. Currently, its bare-bones implementation is as follows: