C++ Protected Class Members are Private???
Mongryong
Mongryong@sympatico.ca
Wed Feb 19 19:47:00 GMT 2003
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.
More information about the Gcc
mailing list