Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Deriving Your Own Stream Classes

Deriving Your Own Stream Classes 

Like any C++ class, a stream class can be derived to add new member functions, data members, or manipulators. If you need an input file stream that tokenizes its input data, for example, you can derive from the ifstream class. This derived class can include a member function that returns the next token by calling its base class's public member functions or extractors. You may need new data members to hold the stream object's state between operations, but you probably won't need to use the base class's protected member functions or data members.

For the straightforward stream class derivation, you only have to write the necessary constructors and the new member functions.

Community Additions

© 2015 Microsoft