【问题标题】:Is there anytthing different with the size() and length() of std::string [duplicate]std::string 的 size() 和 length() 有什么不同吗? 【发布时间】:2012-08-31 02:02:57 【问题描述】: 可能重复:std::string length() and size() member functions 我认为size()和length()都是存储在字符串中的字符的长度,有什么不同吗。 【问题讨论】: 标签: c++ string 【解决方案1】: 没有。它们是相同的。参见 C++11, 21.4.4/3: size_type length() const noexcept; 返回:size()。 【讨论】: