Agent Mulder said:
I want to know why this doesn't work
void f(int a=0,int b=1,int c=2){}
int main()
{
f(); //OK
f(1); //OK
f(1,2); //OK
f(1,2,3); //OK
f(,2,3)// NOT OK
return 0;
}
<Tom>
As others have said, what you've written doesn't work because it's not
C++. As to "why?," Stroustrup devotes several pages in his "The
Design and Evolution of C++" to (i) a proposal to incorporate the kind
of functionality you seem to expect (although not your syntax) into
C++ over ten years ago, (ii) why that proposal was ultimately
rejected, and (iii) how you can accomplish this fairly easily in C++
by using a helper argument class. I've noticed that you posted
several of these "why does C++ do things in this way" kind of
questions, which leads me to believe you really need to pick up a copy
of that book - it will answer most or all the questions you pose, plus
if you're really interested in the answers to the questions you've
been posing (rather than just asking rhetorically)), you'll find it an
interesting read, since it describes the design philosophy underlying
the C++ language, and why the language incorporates some features but
not others. You can buy a used copy on Amazon for less than $10.
Check it out.
</Tom>
The book advice is good. Thank you. For the kind of questions
I pose, I never felt comfortable defending the tool I use. I
try to keep the attitude of the 'amateur', amator in Latin.
Lover. But a scrupulous one, and not easily satisfied. If you find
it rhetoric, I think you mean suspicious.
-X