Reputation: 4820
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
Upvotes: 2
Views: 439
Reputation: 17234
It is allowed because the second parameter you defined has a default value.
Upvotes: 0
Reputation: 16718
Yes, it will (but only in C++, not straight C).
http://en.wikipedia.org/wiki/Default_argument
Upvotes: 0
Reputation: 104698
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.
Upvotes: 3