inheritance - c++, cannot instantiate abstract class -


i have class called enemy , 1 called groundenemy1. keep getting same error cannot "instantiate abstract class", these 2 classes, searched on internet couldn't fix it. hope can me.`

#pragma once #include "vector2f.h" #include "collisionmanager.h" class enemy { public:     enemy(collisionmanager &collmanager);     virtual ~enemy();     void move(vector2f move);     void update(float elapsedsec);     virtual void draw() =0; protected:     bool m_jump;     rectf m_shape;     vector2f m_velocity,m_inputvelocity;     collisionmanager m_collmanager;     float m_jumpspeed, m_acceleration,m_jumpcooldown,m_walkspeed; };  class groundenemie1 :public enemy { public:     groundenemie1(collisionmanager &collmanager,sprite &sprite,rectf shape);     virtual ~groundenemie1();     void draw() override; protected:     sprite m_sprite; }; 

you can't declare object abstract class

because of virtual void draw() = 0 function enemy class abstract class can instantiate object groundenemie1

to understand easily

your groundenemie1 class can called dog, there cat class , fish class. these classes inherites animal (enemy you). can't directly instantiate animal, have more accurate, instiate dog, cat, fish, depending need


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -