0

Why do we use the base class type when defining pointers to derived class objects?

The full code of the lesson (Module 7 Quiz of C++) is below: Dog dogObj; Cat catObj; Pet* pet1 = &dogObj; Pet* pet2 = &catObj; Why is the following incorrect? Dog dogObj; Cat catObj; Dog* pet1 = &dogObj; Cat* pet2 = &catObj;

30th Mar 2022, 6:38 AM
Paek Se
Paek Se - avatar
1 Antwort
0
Is that really the full code? Maybe this lesson can help https://www.sololearn.com/learn/CPlusPlus/1910/?ref=app
30th Mar 2022, 6:48 AM
Ipang