1: class Base
2: { 3: private:
4: int m_nValue;
5:
6: public:
7: Base(int nValue)
8: : m_nValue(nValue)
9: { 10: }
11:
12: protected:
13: void PrintValue() { cout << m_nValue; } 14: };
15:
16: class Derived: public Base
17: { 18: public:
19: Derived(int nValue)
20: : Base(nValue)
21: { 22: }
23:
24: // Base::PrintValue was inherited as protected, so the public has no access
25: // But we're changing it to public by declaring it in the public section
26: Base::PrintValue;
27: };
注意 Base::PrintValue; 该语句并没有添加()