Defines a function f (const string &str, Long pos, long Count =-1)
{
Do something
}
And there was an error in using it.
int main ()
{
String str;
Long pos = 1;
F (str, POS);
}
Tip Information is
Error 1 C2664: "String &string::f (const string &,long,long)": Parameter 1 cannot be converted from "string" to "long" c:\users\wlp\ source. CPP 8 1 String
Find out why books are found
"You can specify a default argument in a function declaration as well as in a function definition, but in one file, you can specify a default argument only once for one parameter, and two: if you provide a default argument in the formal parameter list of a function definition, the default argument is valid only if the function is called in the source file that contains the function definition."
I have defined f () in one file, but it is called in another file, so the default argument cannot be used
The default argument can be specified in the declaration, or it can be specified in the definition, but it is recommended to give the default parameter in the declaration, which is no longer given in the definition, because the function declaration is generally in the header file, so that the file containing the header file can use the default argument, otherwise only one file can be used.
About default arguments