Title: Why do I get C2248 (inaccessible member) with a protected static member?
Tags: c++;inheritance
Question: Let's say I have:

```#include <Windows.h&gt;
#include <iostream&gt;
#include <vector&gt;

st181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16vector<int&gt; Bas181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16m_intList;

class Base
{
public:
    Base();
protected:
    static st181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16vector<int&gt; m_intList;
};

class Derived : Base
{
public:
    Derived();
protected:
    bool fWhatever;
};

class MoreDerived : Derived
{
public:
    MoreDerived();
private:
    HRESULT DoStuff();
};

Bas181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Base()
{

}

Deriv181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Derived()
{

}

MoreDeriv181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16MoreDerived()
{

}

HRESULT MoreDeriv181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16DoStuff()
{
    for (auto it = m_intList.begin(); it != m_intList.end(); it++)
    {
        st181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16cout << *it;
    }
}
```

When I try to compile this, I get "m_intList: cannot access inaccessible member declared in class 'MoreDerived'".

Question: Why can't I access a protected static member in the derived class's DoStuff function?

Comment: `Derived` inherits from `Base` by `private`. Is it your intent?

Comment: `st181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16vector Bas181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16m_intList;` is an error because `Base` is not declared.  Please post the exact code that gave you the error you are asking about

Here is the accepted answer: ```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.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:03/23/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><inheritance>', 'Title': 'Why do I get C2248 (inaccessible member) with a protected static member?', 'ViewCount': 298, 'id': 42966024, 'user_AboutMe': '', 'user_AccountId': 343801.0, 'user_DisplayName': 'Craig', 'user_Reputation': 1836.0, 'user_Views': 302.0, 'user_id': 675738.0}}