November 2001
Beginner
1128 pages
29h 12m
English
The string class overloads the << operator to display string objects. It returns a reference to the istream object so that output can be concatenated:
string claim("The string class has many features.");
cout << claim << endl;
The string class overloads the >> operator so that you can read input into a string:
string who; cin >> who;
Input terminates on end-of-file, reading the maximum number of characters allowed in a string, or on reaching a whitespace character. (The definition of whitespace will depend on the character set and upon the type charT represents.)
There are two getline() functions. The first has this prototype:
template<class charT, class traits, class Allocator> basic_istream<charT,traits>& getline(basic_istream<charT,traits>& ...
Read now
Unlock full access