This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]