Thanks.
Yes, I have tried to comment out 'friend' keyword. It cannot pass compiling.
In class Query, there is a private member q, which points to Query_base:
// interface functions: will call corresponding Query_base operations
std::set<TextQuery::line_no>
eval(const TextQuery &t) const
{ return q->eval(t); }
private:
Query(Query_base *query): q(query),
use(new std::size_t(1))
{}
Query_base *q;
I check below a derived class. There is a constructor:
BinaryQuery(Query left, Query right, std::string op)
Is it a derived class constructor?
There is operator (|: or, &: and etc.) on it.
The original code may not comment accurately.
........
class BinaryQuery: public Query_base {
protected:
BinaryQuery(Query left, Query right, std::string op):
lhs(left), rhs(right), oper(op) { }
// abstract class: BinaryQuery doesn't define eval
std::ostream& display(std::ostream &os) const
{ return os << "(" << lhs << " " << oper << " "
<< rhs << ")"; }
const Query lhs, rhs; // right- and left-hand operands
const std::string oper; // name of the operator
};