派生类向基类转换的可访问性问题。
程序代码:#include <iostream>
using namespace std;
class A
{
public:
void print(int)
{
cout << "haha" << endl;
}
};
class B : protected A
{
public:
void print(int, int)
{
cout << "fuck" << endl;
}
void likeit(A &a);
friend void damnit(A &a);
};
void damnit(A &a)
{
cout << "0_0" << endl;
}
int main()
{
B b;
damnit(b);
b.likeit(b);
system("pause");
return 0;
}程序如上:运行结果错误,但是C++ primer P544 又有如下片段,按照->指向的那一条应该允许访问才对,请问是我理解哪里有误吗?








