The prototypes of std::string::back
are:
char& back();
const char& back() const;
Same applies to std::string::front
.
Why does the second version return a const
reference, as opposed to simply returning the char
by value (as a copy)?
According to the rules of thumb on how to pass objects around, shouldn't small objects be passed by value when there's no need to modify the original?
Aucun commentaire:
Enregistrer un commentaire