C++ question on multiple class inheritance

Could someone explain to me why is there a compilation error in the code 'Endangered* pEndangered = new Panda();' while the rest is correct. I am revising for a test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Given the following multiple inheritance:
class ZooAnimal {};
class Endangered {};
class Bear : protected ZooAnimal {};
class Panda : public Bear, Endangered {};

Check conversions that cause a compile-time error, if any.   

Bear* pBear = new Panda();
    
Endangered* pEndangered = new Panda();

Panda* pPanda = new Panda();
 
Last edited on
Because Endangered is not inherited publicly.

This should fix it:

 
class Panda : public Bear, public Endangered {};
Last edited on
Topic archived. No new replies allowed.