In both cases 3 is assigned to an int
variable that will be determined on function definition.
so in later case - void foo1(int = 3);
// 3 is being assigned to an int
- as at declaration variable name is not required
you can relate this to - void fun(int,int);
NOTE: not from default arguments point of view but from function declaration point of view
// here we have declared two int
variables and its not compulsory to give its name at function declaration time.
EDIT:
As pointed out by @chethan - void foo1(int = 3){ }
is valid in function definition also, but then again whats the use of doing something that you can't use later on (inside function body).
for ex:
void foo1 (int a, int =2)
{
// do something
// here you wont be able to use your second argument if you haven't gave it any name
}
so I think its pointless "Not to give argument name in function definition".