If a string is defined like this
std::string name;
What will be the value of the uninitialized string \"name\" and what size it would be?>
The Standard (C++11, §21.4.2/1) describes the results of default-constructing a std::basic_string
(of which std::string
is a specialization) as follows:
[...] an object of class
basic_string
. The postconditions [...] are indicated in Table 63.
And Table 63 says:
data()
a non-null pointer that is copyable and can have 0 added to it
size()
0
capacity()
an unspecified value