开发者

std::string::length() vs. std::string::size() [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

std::string length() and size() member functions

I always retrieved the length of an std::string via thesize() member function. To be honest I never knew there was a length() member f开发者_开发百科unction too. Well, I've just learnt there is. So I am wondering if there's any difference between the two, and in the likely event of a negative answer, why would there be two member functions that do exactly the same?


Nope! No difference. The more natural name for this function is length() and size() is provided alongside for uniformity with containers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜