简体   繁体   中英

“Error: function does not take 4 arguments” but it does

I'm getting an error, when I try to call a function, that says "function does not take 4 arguments" but I've checked and re-checked and the function definitely does take 4 arguments, and I'm passing arguments of the right type and everything. Here's the code in question:

Calling of function:

brain.minimax(board, board.getDisc('c'), board.getDisc('c'), 0);

Function Declaration in Brian class:

void minimax(Board board, int who, int currentCheck, int iter);

Function definition:

void Brain::minimax(Board board, int who, int currentCheck, int iter)
{
//code
}

I call minimax() at other points in the program in the same way (as far as I can tell i guess) and they don't throw any errors.

The getDisc() funciton returns an int in both the function declaration in the Board class and in its definition. Am I missing something obvious, or is there some other reason that I might be getting this error than the obvious? Thanks in advance for any help

This is going to be some macro bullshittery, probably by including some dodgy C header. If I recall correctly, Windows.h #defines min and max, or something like that.

Try adding #undef minimax before the call site, or inspecting the identifier in your favourite environment to figure out what it actually is. If it shows it as a macro, you can #undef it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM