I've written the following code:
#include <stdio.h>
class A
{
protected:
void foo()
{
printf("class A\n");
}
};
class B : public A
{
void bar()
{
printf("class B\n");
}
};
int main()
{
B *b= new B();
b->foo();
}
And when I'm compiling it I've an error
test.cpp: In function ‘int main()’:
test.cpp:6:7: error: ‘void A::foo()’ is protected
test.cpp:23:9: error: within this context
But in the N3797 working draft said that
protected; that is, its name can be used only by members and friends of the class in which it is declared, by classes derived from that class, and by their friends
and
if a class is declared to be a base class (Clause 10) for another class using the public access specifier, the public members of the base class are accessible as public members of the derived class and protected members of the base class are accessible as protected members of the derived class.