S
Sat
Hi,
I have a simplified version of a problem that I am facing (hope I haven't
oversimplified it). This code doesn't work now and I want to find how I can
make it work. Can I call the derived class version from the base class
pointer and still be able to use a vector with derived element pointers?
class BaseElem { };
class DerivedElem1 { };
class DerivedElem2 { };
class BaseContainer
{
public:
virtual void GetAllElems(std::vector<BaseElem*>& allElems) const;
};
class DerivedContainer1
{
public:
virtual void GetAllElems(std::vector<DerivedElem1*>& allElems) const;
};
class DerivedContainer2
{
public:
virtual void GetAllElems(std::vector<DerivedElem2*>& allElems) const;
};
I have a simplified version of a problem that I am facing (hope I haven't
oversimplified it). This code doesn't work now and I want to find how I can
make it work. Can I call the derived class version from the base class
pointer and still be able to use a vector with derived element pointers?
class BaseElem { };
class DerivedElem1 { };
class DerivedElem2 { };
class BaseContainer
{
public:
virtual void GetAllElems(std::vector<BaseElem*>& allElems) const;
};
class DerivedContainer1
{
public:
virtual void GetAllElems(std::vector<DerivedElem1*>& allElems) const;
};
class DerivedContainer2
{
public:
virtual void GetAllElems(std::vector<DerivedElem2*>& allElems) const;
};