To begin with, you are right, the professor is mistaken. And the fact that he claims that this should work (when it is trivial to show that it is not) means that he probably should not teach C ++. But how to show him?
Just try compiling it with at least two different compilers. If both do not compile it, then there is a very good chance that this is invalid code. This is the fastest way.
If this fails, specify the C ++ standard. Here is the syntax of the call expression, as described in [expr.post] p1 and after nonterminal links:
postfix-expression: ... postfix-expression ( expression-list[opt] ) expression-list: initializer-list initializer-list: ([dcl.init]p1) initializer-clause ...[opt] initializer-list , initializer-clause ...[opt] initializer-clause: assignment-expression braced-init-list braced-init-list: { initializer-list ,[opt] } { }
I am not going to list an assignment-expression, but note that an expression can never be anything, there must be at least one token. This means that an initializer clause can never be anything, and therefore there must always be something between the commas in the function arguments.
source share