You marked your show method as const
, which is not true because it changes the vector of recipes. When I compile the code that you described with gnu gcc 4.2.1, the error is due to the disqualification of the const qualifier, and not the error message.
You can tag your vector with the mutable
keyword, but I suspect that this is not what you really want? Marking the vector mutable, it ignores the constant that the compiler usually applies to the vector Menu::show() const
vector, and it changes every time Menu :: show () is called. If you really want to use a vector, rather than an ordered set like the others, you can add a dirty state flag to let your program know when it should resort or not.
The following code, which I compile by changing the vector to mutable, to show you the difference, but I still recommend that you do not use sorting using the show show method.
#include <vector>
James source share