binding of reference to a value of type drops qualifiers

The error is indicating that you cannot bind a non-const reference to a const-object, as that would drop (discard in other compiler’s errors), disregard or ignore the const qualifier.

What it tries to indicate is that if the operation was allowed you would be able to modify the object through the reference ignoring the fact that the object itself is const, breaking const-correctness.

In your particular code, the function __median in the library takes __a, __b, and __c by const reference and tries to call the __comp function, which in your program (first declaration) takes the second argument by non-const reference. To be able to call __comp(__a,__b) (or any other call to __comp in that function) it would have to bind an object accessible only through a const& to the second argument that takes a non-const reference. This is most probably a typo, since you define compare below with both arguments being const references.

Change the declaration of compare before main to:

bool compare(const Student_info&, const Student_info&);
//                                ^^^^^

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)