Search code examples
c++parametersdefault-parameters

C++ function call with incomplete argument


I got a question about C++ function call.

Suppose I have defined a function like foo(int a, bool b=true); But when I try to call it. I use foo(3), Will this function call use foo(int a, bool b=true) ? Or this is not allowed?

Thanks


Solution

  • Will this function call use foo(int a, bool b=true) ?

    Yes, it will use the default argument and foo(3, true) will be called.