vendredi 1 décembre 2017

(C++) Error binding 'string&' to 'const string'

I'm using C++11 and STL. I have this piece of code:

std::set<std::string>::iterator it;
[...]
std::string &str = *it;

Compiler throws this error:

error: binding reference of type ‘std::__cxx11::string& {aka std::__cxx11::basic_string&}’ to ‘const std::__cxx11::basic_string’ discards qualifiers

Why is it happening?

Aucun commentaire:

Enregistrer un commentaire