cpp/string/basic string/back : Différence entre versions
De cppreference.com
< cpp | string | basic string
(Translated from the English version using Google Translate) |
|||
(3 révisions intermédiaires par 2 utilisateurs sont masquées) | |||
Ligne 1 : | Ligne 1 : | ||
− | |||
{{cpp/string/basic_string/title | back}} | {{cpp/string/basic_string/title | back}} | ||
{{cpp/string/basic_string/navbar}} | {{cpp/string/basic_string/navbar}} | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{| =c++11 | |
CharT& back(); | CharT& back(); | ||
}} | }} | ||
− | {{ | + | {{| sincec++11 | |
const CharT& back() const; | const CharT& back() const; | ||
}} | }} | ||
− | {{ | + | {{end}} |
− | + | Retourne référence au dernier de la chaîne. |}} | |
===Paramètres=== | ===Paramètres=== | ||
− | + | () | |
− | === | + | ====== |
− | + | référence au dernier |}} | |
− | === | + | ====== |
− | + | Constante | |
− | === | + | ====== |
− | {{ | + | {{ |
+ | |||
+ | | | ||
+ | |||
+ | |||
+ | |||
+ | () | ||
+ | { | ||
+ | { | ||
+ | |||
+ | = .back | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | { | ||
+ | c() | ||
+ | = | ||
+ | |||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | }} | ||
===Voir aussi=== | ===Voir aussi=== | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{| cpp/string/basic_string/front}} |
− | {{ | + | {{end}} |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ |
Version actuelle en date du 19 janvier 2019 à 10:28
CharT& back(); |
(depuis C++11) | |
const CharT& back() const; |
(depuis C++11) | |
Retourne une référence au dernier carcatère de la chaîne. Le comportement est indéfini si empty() == true.
Sommaire |
[modifier] Paramètres
(aucun)
[modifier] Valeur de retour
référence au dernier carcatère, équivalent à operator[](size() - 1).
[modifier] Complexity
Constante
[modifier] 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' } }
Résultat :
Exemplars y
[modifier] Voir aussi
(C++11) |
accède au premier caractère (fonction membre publique) |