15.9.2. The Query_base
and Query
Classes
We’ll start our implementation by defining the Query_base
class:
// abstract class acts as a base class for concrete query types; all members are privateclass Query_base { friend class Query;protected: using line_no = TextQuery::line_no; // used in the eval functions virtual ~Query_base() = default;private: // eval returns the QueryResult that matches this Query virtual QueryResult eval(const TextQuery&) const = 0; // rep is a string representation of the query virtual std::string rep() const = 0;};
Both eval
and rep
are pure virtual functions, which makes Query_base
an abstract base class (§15.4, p. 610). Because we don’t intend users, or the derived classes, to use Query_base
directly, ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.