0
this 답이없는 질문이있어서 정말 당황 스럽습니다. 이 행동이 말이 되나요? 표준에 있습니까?기본 액세스의 친구가 파생
난 당신이 게시 된 링크를 읽고 이해 것과class parentFriend;
class parent
{
friend class parentFriend;
public: void f1(){};
protected: void f2(){};
private: void f3(){};
};
class childpub: public parent {};
class childprot: protected parent {};
class childprv: private parent {};
class parentFriend
{
public:
void f()
{
/* which of the following statements will compile? why? why not?*/
parent p; p.f1(); p.f2(); p.f3(); // these will compile
childpub cpub; cpub.f1(); cpub.f2(); cpub.f3();
childprot cprot; cprot.f1(); cprot.f2();
cprot.f3(); // does not compile
childprv cprv;
cprv.f1(); // does not compile
cprv.f2(); // does not compile
cprv.f3(); // does not compile
}
};
대단히 감사합니다. 내 gcc 4.2.4는 여전히 원래 게시물의 것과 같습니다. cpub.f1()과 p.f?()가 컴파일해서는 안되기 때문에 컴파일해야합니다. –