|
-
July 12th, 2006, 10:12 AM
#1
overzealous protection rules
The following doesn’t compile:
struct A
{
A* partner;
void doodah()
{ ++partner->value; } //this is legal
protected:
int value;
};
struct B: public A
{
void foobar()
{ partner->value += 2; } //but this isn’t
};
The error is that B::foobar() can’t access partner->value, due to protection, even though B is an A. Now I'm not a language lawyer, but honestly this should work. B is an A; and A can access the protected members of other A's. But B can't??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|