I need help with coding an example of an std::array being passed into a function. I then will then access the function to demonstrate the array doesn't decay to a ptr when passed to a it.
Moschops why is the prototype of funct the way that it is. Meaning, is this something just to learn, or is there a logical reason for its lengthy coding?
with the added benefit that the template function will work for any object with a size member function that returns a type that std::cout knows what to do with.
Hi Tarik you were absolutely correct. There was no function prototype in that example. You forced me to review and here is the corrected version below.
The function parameter print_array(my_array);
has the same type as array<int,7>&my_array?
When you feed my_array to the function, my_array is an argument. The parameter is the named variable defined in the function header which takes on the value of the argument when the function is invoked.
I understand how to make them work together but why do they work together?
In C++, the type of the parameter determines what types the function will accept as arguments. If an argument is not the same type, or of a type implicitly convertible to the parameter's type, then you cannot call the function with that argument.