What's the preferred C++ idiom to own a collection of polymorphic objects?

后端 未结 4 806
囚心锁ツ
囚心锁ツ 2021-02-02 13:58

Consider the following classes

class Base {
public:
    virtual void do_stuff() = 0;
};

class Derived : public Base {
public
    virtual void do_stuff() { std::         


        
4条回答
  •  孤街浪徒
    2021-02-02 14:12

    Actually you cannot store references in STL, only pointers or real values. So T is Base* Try other things you will have your compiler complaining.

提交回复
热议问题