I have a question about the c++11 pointers. Specifically, how do you turn a unique pointer for the base class into the derived class?
class Base
{
public:
int foo;
}
class Derived : public Base
{
public:
int bar;
}
...
std::unique_ptr<Base> basePointer(new Derived);
// now, how do I access the bar member?
it should be possible, but I can't figure out how. Every time I try using the
basePointer.get()
I end up with the executable crashing.
Thanks in advance, any advice would be appreciated.
See Question&Answers more detail:os