How to make a dynamically allocated array that can hold derived objects in c++ -


Hello, I am doing a project for school that should use a dynamic allocated array of objects. I am wondering where I went wrong on this.

Mammals * Pets = New mammals [gallop]; Pets [Calculation] = New Dog (Template, Tempamark)

There is an error which says that no operator matches these operands for the second line of code.

If my creator helps it, and the dog is the creator.

  Mammal :: mammals (zero) {weight = 0; Name = ""; Cout & lt; & Lt; "Including Mammalian Default Constructor \ n"; } Mammal :: Mammal (Int tempvate, string template) {weight = tempweight; Name = tempname; Cout & lt; & Lt; "Including Mammalian Constructor \ n"; } Dog :: Dog (int tempvate, string template) {SetVette (Template); Setname (tempname); Cout & lt; & Lt; "Inviting Dog Constructor \ n"; }   

Thanks,

To declare you an array Like the indicator,:

  mammals ** pets = new mammals * [Erezes];    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -