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?
Nope! No difference. The more natural name for this function is
length()andsize()is provided alongside for uniformity with containers.