string 类中的size 函数与length有区别吗
1个回答
展开全部
size
语法:
size_type size();
size()函数返回字符串中现在拥有的字符数。
长度(length)
语法:
size_type length();
length()函数返回字符串的长度. 这个数字应该和size()返回的数字相同.
Actually, they have equal results, but semantics is different.
size() act as a method of container, like vector ,set and so forth.
length() represent a property of sequence
语法:
size_type size();
size()函数返回字符串中现在拥有的字符数。
长度(length)
语法:
size_type length();
length()函数返回字符串的长度. 这个数字应该和size()返回的数字相同.
Actually, they have equal results, but semantics is different.
size() act as a method of container, like vector ,set and so forth.
length() represent a property of sequence
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询