Why do I get C2248 (inaccessible member) with a protected static member?

前端 未结 1 903
说谎
说谎 2021-01-23 07:40

Let\'s say I have:

#include 
#include 
#include 

std::vector Base::m_intList;

class Base
{
public:
           


        
1条回答
  •  遥遥无期
    2021-01-23 08:27

    class Derived : Base means class Derived : private Base. The behaviour of private inheritance is:

    • protected members of the base class become private members of the derived class.
    • private members of the base class have no access as members of the derived class.

    So m_intList is:

    • protected in Base
    • private in Derived
    • no access in MoreDerived

    hence your error.

    0 讨论(0)
提交回复
热议问题