You can use the istream class to perform formatted input, or extraction, from a stream buffer using the input operator >>. Consider the following statement, where ins is a reference to an istream object and x is a variable of a built-in type:
ins >> x;
The input operator >> calls ipfx(0). If ipfx() returns a nonzero value, the input operator extracts characters from the streambuf object that is associated with ins. It converts these characters to the type of x and stores the result x. The input operator sets ios::failbit if the characters extracted from the stream buffer cannot be converted to the type of x. If the attempt to extract characters fails because EOF is encountered, the input operator sets ios::eofbit and ios::failbit. If the attempt to extract characters fails for another reason, the input operator sets ios::badbit. Even if an error occurs, the input operator always returns ins.
The details of conversion depend on the format state of the istream object and the type of the variable x. The input operator may set the width variable ios::x_width to 0, but it does not change anything else in the format state.
The input operator is defined for the following types:
In addition, the input operator is defined for streambuf objects.
You can also define input operators for your own types.
Class header file: iostream.h