c++ - Error 1 error C2259: 'Player' : cannot instantiate abstract class -


Why can not I instantiate? Why is the player an abstract class? Have I just announced the pure virtual function in the orbit?

  class object {secure: public: virtual zero DrawOnScreen () = 0; }; Class Creature: Public Object {Public: Virtual Zero DrawOnScreen () = 0; Eat Virtual Zero (object *) = 0; Virtual zero step (direction) = 0; }; Class Player: Public Creatures {Zero Player :: DrawScreen () {cout & lt; & Lt; "Status = (" <";); & lt; get_x () & lt;", "get_y ()  get_x ()) & amp; amp; amp; (get_y () == chk- & gt; get_y ()) & Amp; amp; - & gt; get_isExist ())) {points = points + chk-> Get_weight (); Chk-> Set_isExist (wrong); }} Zero player :: step (direction d) {if (d == u) {y = y + 2; } If (d == below) {y = y - 2; } If (D == right) {x = x + 2; } If (d == left) {x = x - 2; }}}}  

The problem is that you have at least one pure Can not instantiate the class virtual system which is being done due to legacy and wrong override.

This is a typo:

  void player :: eat (object * p)  

You can actually " Eat "means, so you are not really overriding. You should have written this:

  Invalid player :: Eat (object * P)  

On that, you actually get the player :: Scroll for methods within the class, or move the way out of it.

Also, please use C ++ 11 override keywords to avoid such issues, so something like this will give you a compilation error:

  Zero Food (Object * P) Override;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -