std::basic_string::back
De cppreference.com
<tbody>
</tbody>
CharT& back(); |
(depuis C++11) | |
const CharT& back() const; |
(depuis C++11) | |
Retourne une rfrence au dernier carcatre de la chane. Le comportement est indfini si empty() == true.
Paramtres
(aucun)
Valeur de retour
rfrence au dernier carcatre, quivalent operator[](size() - 1).
Complexity
Constante
Example
#include <iostream>
#include <string>
int main()
{
{
std::string s("Exemplary");
char& back = s.back();
back = 's';
std::cout << s << '\n'; // "Exemplars"
}
{
std::string const c("Exemplary");
char const& back = c.back();
std::cout << back << '\n'; // 'y'
}
}
Rsultat :
Exemplars
y
Voir aussi
(C++11) |
accde au premier caractre (fonction membre publique) |