In C++, ios is the base class for all I/O stream classes, fstream handles file input/output operations, and ostream is the base class for output streams. Since all three (ios, fstream, and ostream) are legitimate stream classes in C++'s I/O hierarchy, option D is the correct choice. This question tests knowledge of the C++ stream class hierarchy.