Array of pointer object of base class in C++

Clue to write this program-:

Array of pointer object (of base class) is needed.

Pointer object of base class (take base class as animal), then pointer object of base class will be

Animal *Aptr;

But we need array of that pointer object, so we should initialize an array like this-:

Animal *Aptr[]={ address of pointer object}

then we can perform some functions using that array.


animal class
cow class
dog class
snake class

How this output came?

A1 gave animal class

C1 gave cow class

D1 gave dog class.

S1 gave snake class.

If we hadn’t used pointer object (* sign), we should not have used “&” sign.

Leave a Comment

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site! Scroll to Top