0
Is this declaration correct - void func(int a=7, int b)
5 Answers
+ 6
No the declaration is not correct
You cannot assign the default values from the left side unless you have assigned the value in right side.
It is a syntax error.
It is so, because suppose you have many arguments may be 10 then it will become much more complicated and you have to put sevral "," and which in turn increases the chances of error.
+ 7
Can you use a default argument before a non-default argument in C++? đ¤
+ 5
Just try it on the code playground
+ 3
Thank you everyone, I got my answer
+ 2
It's wrong.
You can declare either
int a=7, b;
Or
int a=7; int b;