One has to start from the first error; some of the later errors may be mere by-products if the compiler is already "sidetracked".
An error message might look "unrelated", if the syntax error such that compiler's "best guess" is way off.
Each error message should list at least the line, where the error occurs (and perhaps column too). That (the row) is the first place to look at, but some errors are actually in preceding lines.
The line 22. The cpp.sh -site's compiler talks about "lambda". Lambda function syntax was added in C++11. Your code does not have proper lambda function on line 22, and most likely isn't supposed to have one either. Assuming that you are not familiar with lambdas, it is no surprise that the error message makes no sense at all.
The code does have an error, and in this case the error message is of limited help (apart from pointing to the line). Your compiler might give a different message. Impossible to tell, for you did not show the error to us.
Edit:
You do use
new
, but have no
delete
anywhere. You hopefully have planned to fix that later, but it is easy to forget such (crucial) details. It is a bad habit to start like that. You have to add three member functions to sort that out. Do you know which?
What if you call display() or findmaxmin()
before calling insert()? Is the MaxMin object consistent before insert()? How should you fix that?
You do have
using namespace std;
, like almost every cursed example has. Your program does not use all symbols from namespace std, so it would be more precise and less error-prone to replace that statement with:
1 2 3
|
using std::cin;
using std::cout;
using std::endl;
|
The findminmax() does not compute the
min
correctly.