Alex Rivera | Logout

std::string::length() vs. std::string::size()

Asked 2011-06-28T21:01:41.210
20

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 function 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?

Edit
Report

1 Answer

16

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

answered 2011-06-28T21:02:55.133

Your Answer