+ 1
Problem in sorting forward_list || cpp
Please look at function func6 in the code and comment on the real issue, I am not able to get the problem. I appreciate everyone's comment.❤️❤️❤️ https://code.sololearn.com/cYj49dIZuS2I/?ref=app
4 ответов
+ 4
If you overload it as a member function, you need to mark operator < (any non-modifying method, really) as const. The comparison function needs to be able to accept values of all value categories, which a non-constant reference can not, and may not modify its arguments anyway.
+ 3
Implement this code at the very top so your code will work.
using namespace std;
+ 2
In func6
To avoid running the code remark this line of code as it gives you error as an output.
//l1.sort();
+ 2
these are some links that can help you fix some of your mistakes.
https://en.cppreference.com/w/cpp/container/forward_list
https://en.cppreference.com/w/cpp/container/forward_list/sort