class Object { /* */ };
and a few derived:
class Derived1 : public Object { /* */ };
class Derived2 : public Object { /* */ };
And I have a function which makes derived objects and returns pointer for Object;
Object *make()
{
return new Derived1();
}
So, this way I have to wrap returned object by smart pointer, but what return type to use?
TYPE? make()
{
return boost::shared_ptr<Derived1>(new Derived1());
}
you can use:
boost::shared_ptr<Object> make()
{
return boost::shared_ptr<Object>(new Derived1());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With