Anders Lind
Anders Lind

Reputation: 4820

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

Upvotes: 2

Views: 439

Answers (3)

shadyabhi
shadyabhi

Reputation: 17234

It is allowed because the second parameter you defined has a default value.

Upvotes: 0

James M
James M

Reputation: 16718

Yes, it will (but only in C++, not straight C).

http://en.wikipedia.org/wiki/Default_argument

Upvotes: 0

justin
justin

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

Related Questions