My task is to display the first and last elements of the list. I have iterators that point to the first and last element of a list. With their help, I am trying to implement a task. Everything works with the first element, with the last - the program crashes. What could be the problem?
typedef list<float>::iterator it;
it i = X.begin(); it j = X.end();
cout << "First element -->> " << *i << "\tLast element -->> ";
cout << *j << endl;