Constructors that use C-style strings let you initialize a string
object from a C-style string; more generally, they let you initialize a charT
specialization from an array of charT
values:
basic_string(const charT* s, const Allocator& a = Allocator());
To determine how many characters to copy, the constructor applies the traits::length()
method to the array pointed to by s
. (The pointer s
should not be a null pointer.) For example, the following statement initializes the toast
object, using the indicated character string:
string toast("Here's looking at you, kid.");
The traits::length()
method for type char
uses the null character to determine how many characters to copy.
The following relationships hold after the constructor is called:
• The data()
method returns a pointer to the first element of a copy of the array s
.
• The size()
method returns a value equal to traits::length()
.
• The capacity()
method returns a value at least as large as size()
.
3.22.61.218