Doing an assignment with one aspect being working out the maximum amount of a material used. Loading the material used into an array, then a maximum function that returns the highest. However, I get an out of range error. I thought I understood out of range issues with arrays..I only have 5 elements! Please help!
Output==================
0.61/1.7/0.52/1.34/0.25
The minimum isterminate called after throwing an instance of 'std::out_of_range'
what(): array::at: __n (which is 5) >= _Nm (which is 5)
also note that you are passing the array by value, rather than by reference - so a copy of the array is performed when passing to maximum. Use const array<float, 5>& instead.
Also note, that there is an easier way to calculate the maximum value
We are only 1st year uni - and we are only just getting into passing by reference.
Also, this assignment is supposed to be modular, and there is many values to pass through minimum, maximum, and average functions.. So your suggestion is a lil over my head and doesn't fit the brief, but thank you for the insight.