Why is virtual function not being called?

后端 未结 6 1920
挽巷
挽巷 2021-01-26 07:00
//GUITEXT
class guitext : public entity {
public:
    guitext(graphics *gfx, std::string _text, float _x, float _y, 
        float _size, float timeToLive);
    bool upd         


        
6条回答
  •  萌比男神i
    2021-01-26 07:23

    You made a vector of entity. Those objects always have type entity. If you want to invoke polymorphism, they need to be pointers or references. How can a vector of entity store a guitext? There's not enough space, it doesn't know how to destroy it, etc etc.

提交回复
热议问题