If class Aardvark derives from class Animal, and it replaces the inherited output() function, which version of the outpu
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
If class Aardvark derives from class Animal, and it replaces the inherited output() function, which version of the outpu
If class Aardvark derives from class Animal, and it replaces the inherited output() function, which version of the output() function gets called in the following 2-line code segment? Animal* a = new Aardvark; a->output(); it's a trick question! This code will not compile, because the data types do not match in the first line Animal::output is called, because of the data type declared for a Aardvark::output is called, because the object is an Aardvark it depends on the original declaration of the output function in the Animal class
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!