关于派生类访问基类protected对象
基类Queryclass Query {public:const vector<location>* locations() const { return &_loc; }// ...protected:vector<location> _loc;// ...};派生类:NameQueryboolNameQuery::compare( const Query *pquery ){// ok: 自己的 Query 子对象的 protected 成员int myMatches = _loc.size();// 错误: 没有 "直接访问另一个独立的 Query// 对象的 protected 成员" 的权利int itsMatches = pquery->_loc.size();return myMatches == itsMatches;}