What error do you get? (PS: I am not quite sure you are allowed to have fixed length arrays as function parameters - there is no way for the function to check the length of a passed array on runtime).
@matthewfs
Please post your exact error message(s).
@hanst99
You can, the length is part of the type. Type promotion allows you to drop the length into a general pointer, so that you can pass things of different lengths...
So while you are allowed to put array lengths in function parameters, does it actually achieve anything other than informing the programmer of what is expected to be passed to it?
I read in a C++ book that void (int*) and void (int [some_number]) are exactly the same. But then I also read elsewhere that the book wasn't so great ;)
Yeah that's what I meant. I know the types of parameters and arguments must match, but I read that the compiler ignores the numbers in arrays in the parameter list, so that
Make sure you set your compiler to the strictest level of warning and error checking.
Line 28 should have failed to compile, because do_something1() expects a specific type: an int[3].
Everything else works because lines 6 and 11 both declare an argument pointer, not an array. An array will "type promote" (or degenerate) into a pointer, as it does on lines 30 through 34.
I set the warning level to 4 and 'treat warnings as errors' to true and recompiled. (I added the cout lines because there was a warning about not using the parameters in the functions.)
This still compiled. The only higher level of warnings was 'enable all warnings' and using this just generated loads of complaints about unused inline functions in <iostream> Still nothing about type mismatches.