Value and size of an uninitialized std::string variable in c++

前端 未结 5 1582
既然无缘
既然无缘 2020-12-09 07:44

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?

5条回答
  •  抹茶落季
    2020-12-09 08:18

    Default constructed user-defined types are not uninitialized. The default constructor defines an empty string (i.e "") with a size/length of zero.

提交回复
热议问题