This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
C++ Protected Class Members are Private???
- From: Mongryong <Mongryong at sympatico dot ca>
- To: gcc at gnu dot org
- Date: 19 Feb 2003 14:10:48 -0500
- Subject: C++ Protected Class Members are Private???
Okay, I'm not sure what the spec says, but GCC treats 'protected' member
variables/methods as private in the following example:
class BinaryTree {
protected:
Object* key;
BinaryTree* left;
BinaryTree* right;
//....
};
class BST: public BinaryTree {
public:
void insert(Object& obj) {
//....
}
//....
};
class AVLTree: public BST {
protected:
void balance () {
//...
// LL rotation
right = left;
// now, this generates a compiler error!!!
// right->left: left is protected and can't be accessed??
left = right->left;
}
pubic:
void insert (Object& obj) {
BST::insert(obj);
balance();
}
//...
};
So, is this a bug? Thanks.