Yes. In your example, it becomes a protected member of the derived class.
If a base class has a protected member, is it also a member of the derived class?
"Within the class, the keyword protected has exactly the same effect as the keyword private...The difference between protected and private members only becomes apparent in a derived class. Members of a base class that are declared as protected are freely accessible in the function members of a derived class, whereas the private members of the base class are not."(Ivor Horton's Beginning C++, p 588)
Try experimenting. Here is an example:
I keep reading and reading, somehow it is still a mystery to me.
Now trying adding this function to the public section of Base:
using namespace std;
Base(int n1, int n2, int n3)
publicNum = n1;
protectedNum = n2;
privateNum = n3;
class Derived : public Base
Derived(int num1, int num2, int num3): Base(num1, num2, num3)
/*error C2248: 'privateNum' : cannot access private member declared in class 'Base'*/
int main ()
Derived d(1, 2, 3);
and add this code to the end of main():
cout<<publicNum<<" "<<protectedNum<<" "<<privateNum<<endl;
My book says that all members of the base class are inherited--it's just a question of whether they are accessible or not; and private members in the base class are not accessible by members of the derived class.