Just playing around a little with C++. What I really want to do is to be able to setup a function with default values defined for an array or pointer argument. To keep things simple, let's just use an array. Like so:
void experimentA(char a[3] = {'a', 'b', 'c'});
The compiler (LLVM GCC 4.2 with GNU99) complains "Expected expression". That is quite obtuse, but I was told by colleagues that this is happening because the 'value' I'm trying to assign is statically allocated, whereas the variable I'm trying to assign it to (a[3]) is auto.
But I'm not completely sure if that's the case, since I'm able to do this:
void experimentB(char a[3] = "abc");
And the compiler merely warns me that string-literal to char* conversion is deprecated.
I don't understand how "abc" differs fundamentally from {'a','b','c'} in order to cause this discrepancy. Any insight is much appreciated!