Array of pointer object of base class

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.

Output-:

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.

Be the first to comment

Leave a Reply

Your email address will not be published.


*