More Assignment Methods
In addition to the basic assignment operator, the string
class provides assign()
methods, which allow you to assign a whole string or a part of a string or a sequence of identical characters to a string
object. Here are the prototypes for the various assign()
methods:
basic_string& assign(const basic_string& str);basic string& assign(basic_string&& str) noexcept; // C++11basic_string& assign(const basic_string& str, size_type pos, size_type n);basic_string& assign(const charT* s, size_type n);basic_string& assign(const charT* s);basic_string& assign(size_type n, charT c); // assign n copies of ctemplate<class InputIterator> basic_string& assign(InputIterator first, InputIterator last);basic_string& ...
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.