I came across with a confusing question during an examination. Please help me to understand this concept. Code snippet is including here :
void xyz(int a = 0, int b, int c = 0)
{
cout << a << b << c;
}
Now the question is which of the following calls are illegal?
(Assume h and g are declared as integers)
(a) xyz(); (b) xyz(h,h);
(c) xyz(h); (d) xyz(g,g);
Codes:
(1) (a) and (c) are correct (2) (b) and (d) are correct
(3) (a) and (b) are correct (4) (b) and (c) are correct
I tried to compile the code in C++ and I got this error:
error:expected ';',',' or ')' before '=' token
void xyz (int a = 0, int b = 0, int c = 0)
Help me understand the concept.