I have this code:
AST* visit(AST* node)
{
    if (node->name == "BinOp")
    {
        return visit_BinOp(node);
    }
    generic_visit(node);
    return nullptr;
}
AST is a class that only has a name member, defaulted to "undefined". I'm trying to pass an AST object (node) into visit_BinOp, which expects a BinOp object. BinOp is a child of AST. Here is visit_BinOp:
int visit_BinOp(BinOp* node)
{
    if (node->op->type == PLUS)
    {
        //code
    }
}
It is giving me this error:
argument of type "AST *" is incompatible with parameter of type "BinOp *".
I'm unsure of what to do to fix this. "node" is a generic AST* that could be a BinOp* or a different class that is also a child of AST.
AST:
class AST
{
public:
    string name = "undefined";
};
BinOp:
class BinOp : public AST
{
public:
    AST* left;
    Token* op;
    AST* right;
    BinOp(AST* left, Token* op, AST* right)
    {
        this->left = left;
        this->op = op;
        this->right = right;
        name = "BinOp";
    }
};
