inheritance - C++ error C2248: cannot access private member declared in SUPER class -
i have looked through similar questions stackoverflow haven't found answer yet.
here's subclass declaration:
class enemy : public entity { public: enemy(); ~enemy(); }; // line shows error...
here's superclass declaration:
class entity { //member methods: public: entity(); ~entity(); bool initialise(sprite* sprite); void process(float deltatime); void draw(backbuffer& backbuffer); void setdead(bool dead); bool isdead() const; bool iscollidingwith(entity& e); float getpositionx(); float getpositiony(); float gethorizontalvelocity(); void sethorizontalvelocity(float x); float getverticalvelocity(); void setverticalvelocity(float y); protected: private: entity(const entity& entity); entity& operator=(const entity& entity); //member data: public: protected: sprite* m_psprite; float m_x; float m_y; float m_velocityx; float m_velocityy; bool m_dead; private: };
i have subclass called playership using same structure, 1 works fine. went wrong?
private: entity(const entity& entity); entity& operator=(const entity& entity);
you made entity class uncopyable , unassignalbe. enemy class doesn't have these member functions declared. compiler obliges , generates them you. no problem far, assume attempt copy enemy...
a minimal example getting similar error:
class entity { //member methods: public: entity(); ~entity(); private: entity(const entity& entity); entity& operator=(const entity& entity); }; class enemy : public entity { public: enemy(){} ~enemy(){} }; int main() { enemy e1, e2 = e1; return 0; }
Comments
Post a Comment