It is a commonly held belief that the the C++ standard library is not generally intended to be extended using inheritance. Certainly, I (and others) have criticised people who suggest deriving from classes such as std::vector
. However, this question: Can what() return NULL for exceptions? made me realise that there is at least one part of the Standard Library that is intended to be so extended - std::exception
.
So, my question has two parts:
Are there any other standard library classes which are intended to be derived from?
If one does derive from a standard library class such as
std::exception
, is one bound by the interface described in the ISO Standard? For example, would a program which used an exception class who'swhat()
member function did not return a NTBS (say it returned a null pointer) be standard conforming?