October 2011
Beginner to intermediate
1200 pages
35h 33m
English
A constructor that uses a range uses an iterator-defined range in the style of the STL:
template<class InputIterator>basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
The begin iterator points to the element in the source at which copying begins, and end points to one past the last location to be copied.
You can use this form with arrays, strings, or STL containers:
char cole[40] = "Old King Cole was a merry old soul.";string title(cole + 4, cole + 8);vector<char> input;char ch;while (cin.get(ch) && ch != '\n') input.push_back(ch);string str_input(input.begin(), input.end());
In the first use, InputIterator is evaluated to type const char *. In the second use, ...
Read now
Unlock full access