I have a base class that looks something like this:
class Base
{
public:
typedef std::shared_ptr<Base> ptr_t;
typedef std::weak_ptr<Base> wptr_t;
enum class Type { foo, bar, baz };
Type x;
};
I would like these inner types to be publicly available so that I can do things like Base::ptr_t my_ptr(new Base);and so on. But if I create a new class like this ...
class Derived : public Base
{
};
Unfortunately, Derived::ptr_tit is still the base pointer. I would like Derived to publicly inherit xfrom Base, but not inherit ptr_t, wptr_tor Type. for instance
Derived a;
a.x = Base::Type::foo;
a.x = Derived::Type::foo;
Is it possible, perhaps some kind of magical use, friendor virtualsomething like that?
source
share