my question is how do I find the maximum value in a list, I get an error with largest[0] line of code
#include <iostream>
#include <list>
using namespace std;
int main()
{
int n = 0, num = 0;
list<int> largest{};
cout << "Enter number of values (1-100): ";
cin >> n;
cout << endl;
for (int i = 0; i < n; i++)
{
cout << "Enter number: " << i + 1 << " : ";
cin >> num;
largest.push_back(num);
}
for (int i = 1; i < n; i++)
{
if (largest[0] < largest[i])
{
largest[0] = largest[i];
}
}
return 0;
}