error: passing 'const …' as 'this' argument of '…' discards qualifiers
The error message tells you that you that you are casting of const
from your object in operator<
function. You should add const
to all member functions that don't modify member.
bool operator<(const stockType& stock) const
// ^^^^^
{
return (symbols < stock.symbols)
}
The reason why compiler complains about operator<
is because std::sort
uses operator<
to compare the elements.
Also you have another syntax error in insert
function.
Update:
void insert(const& stockType item);
to:
void insert(const stockType& item);
// ^^