在c++中子類調用父類方法的方法和java所用的方式不一樣,
java使用super指針就可以調用,c++中雖然也有this指針,但是不能用super去調用父類方法。
c++用的方法爲:fatherClass::fatherFunction().
1、java中的方法
public Expr visit(BinaryExpr e) {
if (isTupleComparison(e)) {
if (e.op == BinaryOp.EQUAL) {
return equal;
} else {
return new UnaryExpr(UnaryOp.NOT, equal);
}
} else {
return super.visit(e);
}
}
2、c++的方法
expr* flatten_tuple_comparisons::visit(binary_expr* e)
{
if(is_tuple_comparison(e))
{
if(e->op == *binary_op::EQUAL)
{
return and_tuple;
}
else
{
return new unary_expr(*unary_op::NOT,*and_tuple);
}
}
else
{
return father_visitor::visit(e);
}
}