Query q = Query("fiery") & Query("bird") | Query("wind");
(a) List the constructors executed in processing that expression.
WordQuery(const std::string &) * 2
| /* WordQuery("fiery") WordQuery("bird") */
v
Query(const std::string &s) * 2
|
v
Query(const Query &) or Query(Query &&) * 2 /* call synthesized version */
|
v
BinaryQuery(const Query &, const Query &, std::string)
|
v
AndQuery(const Query &, const Query &)
|
v
Query(std::shared_ptr<Query_base>) WordQuery(const std::string &)
| | /* WordQuery("wind") */
| v
| Query(const std::string &s)
| |
+-----------------------------------+
|
v
Query(const Query &) or Query(Query &&) * 2 /* call synthesized version */
|
v
BinaryQuery(const Query &, const Query &, std::string)
|
v
OrQuery(const Query &, const Query &)
|
v
Query(std::shared_ptr<Query_base>)
(b) List the calls to rep
that are made from cout << q
.
Query::rep /* q.rep() */
|
v
BinaryQuery::rep /* q->rep() */ /* inherited by OrQuery */
|
+--------------------------------+
| |
v v
Query::rep /* lhs.rep() */ Query::rep /* rhs.rep() */
| |
| v
| WordQuery::rep /* q->rep() */ /* wind */
v
BinaryQuery::rep /* q->rep() */ /* inherited by AndQuery */
|
+--------------------------------+
| |
v v
Query::rep /* lhs.rep() */ Query::rep /* rhs.rep() */
| |
v v
WordQuery::rep /* q->rep() */ WordQuery::rep /* q->rep() */
/* fiery */ /* bird */
(c) List the calls to eval
made from q.eval()
.
Query::eval /* q.eval() */
|
v
OrQuery::eval /* q->eval() */
|
+------------------------------------+
| |
v v
Query::eval /* lhs.eval() Query::eval /* rhs.eval() */
| |
v v
AndQuery::eval /* q->eval() */ WordQuery::eval() /* q->eval() */
|
v
+------------------------------------+
| |
v v
Query::eval /* lhs.eval() */ Query::eval /* rhs.eval() */
| |
v v
WordQuery::eval() /* q->eval() */ WordQuery::eval() /* q->eval() */