Relationship between ios_base and ios_base::failure

ios_base is a class at the top of the class hierarchy in the IOStreams library.

The basic_ios<> class template derives from ios_base, and therefore constitutes the 2nd rung in this hierarchy.

Now, streams can be configured to throw exceptions which are of type ios_base::failure, which is a class.

Since ios_base::failure is a class and ios_base is also a class, I must conclude that ios_base::failure is a class defined _within_ the ios_base class. (A class defined within another class)

Is this conclusion correct?

Yes. Both failure and Init are member classes of std::ios_base
If you look at the documentation for it, it does mention that it's an "embedded" class, so yup you're right. has a more up-to-date implementation detail:

std::ios_base::failure may be defined either as a member class of std::ios_base or as a synonym (typedef) for another class with equivalent functionality
Thanks, Cubbi! I bookmarked that page :)
Topic archived. No new replies allowed.