I have all of the variables coded above, but I am not sure how to pick out the vectors and print out all of the elements of the vectors to find the largest. What is the best way to do so?
I have the vector in this function and using <push_back> to place the values in the vector.
I tried using the max_element in the program but i get a no matching funtion error:
main.cpp:188: error: no matching function for call to 'max_element(std::vector<double, std::allocator<double> >&)'
A few notes:
1. You can't directly copy Athar's code snippet. You will have to change a few tiny things (like the name of the vector being used.) :)
2. You need to #include <algorithm> to use the function.
3. If you continue to have problems, you could do the search yourself.
3.1. Have a temporary double initialized to the first element of your vector.
3.2. Go over each element of the vector.
3.2.1. If the element is smaller than the value recorded in your temporary double, ignore it.
3.2.2. If the element is larger than the value recorded in your temporary double, reassign the temporary double to that element.
3.3. When your loop is over, if all went well, the temporary double will contain your largest element. :)
It's not necessary to post the whole code, just the relevant parts. And always the full error message. There's usually no point in posting without providing both.
And sorry, the third parameter was nonsense.