"" , .
, :
struct A
{
protected:
struct DerivedOnlyAccessToken{};
public:
void foo() {}
public:
void privilegedStuff( DerivedOnlyAccessToken aKey );
};
struct B: A
{
void doPrivelegedStuff( A& a )
{
a.privilegedStuff( DerivedOnlyAccessToken() );
}
};
int _tmain(int argc, _TCHAR* argv[])
{
A a;
a.foo();
a.privilegedStuff( A::DerivedOnlyAccessToken() );
B b;
b.doPrivelegedStuff( a );
return 0;
}
This is not my idea. I read it in some place. Sorry, I don’t remember what an idea it was.
I expect the compiler to be able to exit the aKey parameter.
source
share