Streams and File Input and Output
The iostream library is the object-oriented library that renders output and input functionality employing streams.
A stream is the abstract entity that constitutes the measure on which ouput and input operations are executed. A stream could fundamentally be constituted as the origin or goal of characters of uncertain length.
Streams are by and large linked to the physical source or destination of characters, like the disk file, the keyboard, or the console, Thus the characters gotten or composed to/from the abstraction referred as stream are physically input/output to the physical instrument. For illustration, file streams are C++ objects to manipulate and interact with files; Once the file stream is employed to open the file, any input or output operation executed on that stream is in accord with physical laws pondered in the file.
To engage with streams, C++ renders the standard iostream library, which comprises the accompanying components:
Basic class templates
The base of iostream library is the power structure of class templates. The class templates render most of the practicality of the library in the type-independent manner.
This is the set of class templates, each one bearing two template parametric quantity: the char type (charT) parametric quantity, that ascertains the type of components that are going to be controlled and the traits parametric quantity, that renders additional characteristics particular for the detail type of components.
The class templates in this class power structure have the similar name as their char-type instantiations but with the prefix basic_. For illustration, the class template which istream is instantiated from is referred as basic_istream, the one from which fstream is is referred as basic_fstream, and Thus on... The only exclusion is ios_base, which is by itself type-independent, and thus is not established on the template, but is the regular class.
Class template instantiations
The library comprises 2 standard sets of instantiations of the total iostream class template hierarchy: one is constrict-oriented, to control components of type char and some other one, broad-oriented, to control components of type wchar_t.
The narrow-oriented (char type) instantiation is in all probability the best known component of the iostream library. Classes such as ios, ofstream and istream are narrow-oriented. The classes of the wide-oriented (wchar_t) instatiation accompany the similar naming conventions as the narrow-oriented instantiation but with the name of each class and object prefixed with the w character, constituting wios, wistream and wofstream, as the illustration.
Standard objects
As component of the iostream library, the header file <iostream> declares definite objects that are employed to execute output and input operations on the standard output and input.
They are divided in 2 sets: narrow-oriented objects, which are the common cout, cin, clog and cerr their wide oriented counterparts, declared as wcout, wcin, wclog and wcerr.
Types
The iostream classes barely employ fundamental forms on their prototypes of the member. They by and large employ outlined forms that reckon on the attributes employed in their instantiation. For the default wchar_t and char instantiations, streamoff, streamsize and , forms streampos are employed to make up positions, sizes and offsets in the order given.
Manipulators
Manipulators are global functions planned to be employed in concert with insertion (<<) and extraction (>>) operators executed on iostream stream objects. They by and large modify attributes and formatting settings of the streams. endl, hex and scientific are some illustrations of manipulators.
Organization
The hierarchy and library of the classes is fragmented in various files:
ñ <ios>, <istream>, <ostream>, <streambuf> and <iosfwd> are not in general comprised at once in nearly all C++ programs. They depict the base classes of the power structure and are mechanically comprised by other header files of the library that comprise derived classes.
ñ <iostream> declares the objects employed to communicate via the standard input and output (comprising cin and cout).
ñ <fstream> delineates the file stream classes (like the template basic_ifstream or the class ofstream) as well as the internal buffer objects employed with these (basic_filebuf). These classes are employed to manipulate files employing streams.
ñ <sstream>: The classes outlined in this file are employed to keep in line string objects as if they were streams.
ñ <iomanip> declares some standard manipulators with parametric quantity to be employed with insertion and extraction operators to alter formatting options and internal flags.
Students can get solutions for Streams and File Input and Output in C++ online. ExpertsMinds interactive academic session will make learning Streams and File Input and Output in C++ easy. Get answers online to all the questions, assignments, homework on Streams and File Input and Output in C++ , under the expert guidance of our tutors. Expertsmind.com offers Streams and File Input and Output in C++ online tutoring service, Streams and File Input and Output in C++ homework help and Streams and File Input and Output in C++ anytime from anywhere 24x7.