Check the true statement out of the two statements below (there is only one correct choice): Group of answer choices A. Without type coercion being employed, a base class reference can only point to a base class object, not a derived class object. B. Without type coercion being employed, a derived class reference can only point to a derived class object, not a base class object.

Respuesta :

Answer:

B. Without type coercion being employed, a derived class reference can only point to a derived class object, not a base class object.

Explanation:

A derived class is a sub class of its base class. A base class pointer can point to derived class objects.

Base class is not part of its derived class(s), so a pointer to derived class can't point to base class objects.

A good analogy can be pets (base class) and dog (derived class).

A pet pointer can point to dog object (A dog is a pet). And can call methods on it and do other stuff, since dog inherits pet class's data and methods.

A dog pointer can't point to pet object (there can be other types of pets besides dog). And call methods on it, since some of the Dog class's methods and data might be its own and are not defined in pet class.

ACCESS MORE
EDU ACCESS