Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefinition of default argument

I have encounter an error saying "redefinition of default argument" while I am compiling some codes. This is the line that is throwing the error:

bool wCommandDistributor::initialise (const bool server = true, const short ncmds=0,
                byte (*cmds)[CMD_MAX_RECLEN] = (byte (*)[CMD_MAX_RECLEN])0)

Is there anyway that I can rewrite the code in order to solve the error? This is not a code written by me. I am helping to rewrite the code and it is written in C++.

Thanks in advance.

like image 892
user1744424 Avatar asked Dec 25 '22 03:12

user1744424


1 Answers

The compiler says it all, you are redefining the default arguments of initialise (even though they might be the same).

The default arguments were probably already defined in the function declaration. You don't need to redefine them in the function definition, and so you should remove them.

But only the ones that were already defined in the declaration, it might be that some were not defined in the declaration, only in the definition. In this case you should naturally leave them.

like image 56
Rakete1111 Avatar answered Jan 10 '23 16:01

Rakete1111