If I have a base class called Book and create an array of Book pointers, how can I dynamically create an instance of a NonFiction or Fiction (both derived classes) in my Book pointer? I added what I am trying to do but unsure how the correct syntax for doing something like this is.
Book* v;
v = new Book[10]
v[2] = new Fiction
Aucun commentaire:
Enregistrer un commentaire