Default Arguments

Why are these function declarations illegal?
void t1(int x, int y = 0, int z);
void t2(int x = 0, int y = 0, int z);
Last edited on
t2(1, 2);
Now tell me values of x, y and z;

Only trailing arguments can be replaced by default values by standard (p. 8.3.6.1).

So if last argument does not have a default value, it is pointless to declare previous arguments with default values, because you will not able to use it. So compiler thinks that you made an error here and points to it. (I didn't find statement that it should be an error thought).
Last edited on
Topic archived. No new replies allowed.