Question: ```
#include <iostream>
using namespace std;

class A {
    public:
        A ();
        virtual ~A();
};

class B: protected A {
    public:
        virtual ~B ();
};

int main() {
    A* pb = new B;//A is inaccessable base of B
    return 0;
}

```

when I run the code above, it tells me A is inaccessable base of B, the pb is a pointer, which pointer to the B, what is the problem?

Answer: 
B is protected inherited from A, thus only subclasses of B 'knows' it's an A. the static main() doesn't 'know' it, because it does not inherit from B.

you can access B as an A in this situation:

```
class C: B {
    void foo() {
        A* pb = new B;
    }
};

```

if you need it in the main, you would need to change B to public inherit from A
The problem is that you inherit B from A as `protected`, and therefore outside code is not allowed to 'know' that B inherits from A. Replace protected with public, and the code should compile.