string(iter1, iter2);
1th: Two iterators must point to the same container.
2nd: Iter2 must be >=iter1.
3rd: If Iter1 equals iter2, then the result is empty []
Another very useful point of reference for reverse iterators is the following procedure to illustrate:
int main () {string str1 ="ABC";cout <<"Str1.rend ()-Str1.rbegin () is"<< str1. Rend()-STR1. Rbegin() << Endl;cout <<"Str1.rbegin ()-Str1.rend () is"<< str1. Rbegin()-STR1. Rend() << Endl;cout <<"*str1.rbegin () is"<< *STR1. Rbegin() << Endl;cout << String (str1. Rbegin(), str1. Rend()) << Endl;cout << *STR1. Rend() << Endl; Errorcout << String (str1. Rend(), str1. Rbegin()) << Endl; ErrorGetChar ();}
Output is
str1.rend() - str1.rbegin3str1.rbegin() - str1.rend() is -3*str1.rbegin() is ccba
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
About initializing a string with two iterators in C + +