Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 312 Bytes

File metadata and controls

17 lines (14 loc) · 312 Bytes

编写一条 typeid 表达式检查两个 Query_base 对象是否指向同一种类型。 再检查该类型是否是 AndQuery 。

答:

Query_base *pqb1 = ...;
Query_base *pqb2 = ...;

if (typeid(*pqb1) == typeid(*pqb2))
{
    if (typeid(*pqb1) == typeid(AndQuery))
    {
        // ...
    }
}