Severity Code Description Project File Line Suppression State
Error C2679 binary '<<': no operator found which takes a right-hand operand of type 'const studentinfo' (or there is no acceptable conversion) studentrecord c:\users\admin\desktop\visualstudio\examreview\studentrecord\source.cpp 65
i thought i have taken care of it, because i have overloaded the << operator
ostream& operator <<(ostream& os, studentinfo & c)
{
os << c.name << " " << c.grade ;
return os;
In instantiation of 'void print(T&) [with T = std::set<studentinfo>]':
112:10: required from here
65:8: error: no match for 'operator<<' (operand types are
'std::ostream {aka std::basic_ostream<char>}' and 'const studentinfo')
Your code at line 112 states: print(ss);
which causes a call to:
1 2 3 4 5 6 7 8
template<typename T>
void print(T& c)
{
cout << "\nHere is the List: \n";
for (auto& x : c)element
cout << x << " ";
cout << "\n" << endl;
}
{
auto && __range = range_expression ;
auto __begin = begin_expr ;
auto __end = end_expr ;
for ( ; __begin != __end; ++__begin) {
range_declaration = *__begin;
loop_statement
}
}
Since std::set is an associative container where the value type is the same as the key type, http://en.cppreference.com/w/cpp/container/set
because of the following requirements from the standard:
C++14 final_draft (n4140) - 23.2.4.6:
For associative containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators.
the requested std::set::iterator, is declared const.