istream::istream explicit istream (streambuf * sb); | istream |
cplusplus.com |
Construct an object.
Sets the initial values to inherited class members.
This is done by calling inherited function:
init(sb)
Parameters.
Return Value.
None (constructor).
Example.
// istream constructor
#include <iostream>
#include <fstream>
using namespace std;
int main () {
filebuf fb;
fb.open ("test.txt",ios::in);
istream is(&fb);
cout << char(is.get());
fb.close();
return 0;
}
This code uses a filebuf object (derived from streambuf)
to open the file test.txt.
The buffer is passed as parameter to the istream constructor, associating
it to the stream.
You will seldom use istream objects directly like in the previous example,
you will rather use objects of derived classes like ifstream,
istringstream or your own ones.
Basic template member declaration ( basic_istream<charT,traits> ):
explicit basic_istream ( basic_streambuf<charT,traits>* sb ); |
See also.
ios::init
istream class