string operation and vector operation
string operation, like processing characters in a string or changing the characteristics of a character in a string are handled
![]()
by a set of library function defined in the cctype header.
/*1.first c indicates that the header is part of the C library.
2.second c indicates that we are processing characters. I.e. char
*/
![]()
by member function of string class. //like s.empty()
题外话:
dot operator . //left-hand must be an object of class type,right-hand must be the name of a member of the object.
scope operator :: //used to access names in namespace
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Iterator for containers (and string)
types(built-in types & class types) that have iterators have members that return iterators
using iterators
1.empty container check by comparing the iterators returned by begin and end
2.moving iterators from one element to another by ++
Iterator types //they are library types
we don't need to know the precise type of an iterator //iterator and const_iterator
BUT we need to understand is that there is a collection of types that are related conceptly AND type is an iterator if it supports a common set of action.
![]()
![]()
each container class defines a type named iterator
All of the library containers have iterators, but only a few of them support the subscript operator