# Include <iostream>
# Include <vector>
# Include <iterator>
# Include <string>
Using namespace STD;
Int main ()
{
Vector <string> VEC;
String str1 ("AAA"), str2 ("BBB"), * P;
Vector <string >:: iterator it;
VEC. insert (VEC. Begin (), str1 );
VEC. insert (VEC. End (), str2 );
For (IT = Vec. Begin (); It <Vec. End (); It ++)
Cout <* It <Endl;
Cout <Endl;
For (P = Vec. Begin (); P <Vec. End (); P ++)
Cout <* P <Endl;
Return 0;
}
The iterator is a generalized pointer, And the pointer meets all the requirements of the iterator. The iterator is the interface of STL algorithm, and the pointer is the iterator. Therefore, STL algorithm can use pointers to operate non-STL containers based on pointers.
Iterator is a class and P is a pointer. Do not confuse the class with the pointer.
As for the above example, some ides can be compiled (VC ++ 6), and some cannot (VC ++. net2003), can only be said to be the reason for implementing the C ++ standard support!
Thank you for your advice! Thank you!