Why won't a derived class work in an array? (C++) -


I have created a square with a function move, which is called vir:

  Class Vir {public: vir (int a, int b, char s) {x = a; Y = b; Sym = s;} zero step () {}};  

(This variable comes from a square with xx, int y, and char sym) I have received a square from it, which is called subvir:

Sub-classes of the class: Public heroes {public: Subway (int a, int, four, s) {x = a; Y = b; Sym = s;} zero step (); }; Subvir :: move () {x ++; Return; }

And then I created an array of dog, and put a subway in it

  subvir sv1 (0,0, 'q'); Vir vir_RA [1] = {sv1};  

But when I try to use sv1.move ():

vir_RA [0] .move ();

It uses the heroic Subvir Move ({x ++}) instead of ({}} I have tried to make a well and sv_ a viral sv1, and it works, And it also works when I make them both subvir, but I need to separate them. I tried to make vir :: move () a pure virtual, but then I get an error in proving the array. Does anyone know that when I use it from the array, how can I work?

Instead of an array of examples, in this case an array of pointers is required [Vir] Instead of vir []


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -