Denis said:
Since the said classes have non-virtual destructors, it is immoral to
inherit from them publicly (this has been beaten to death). It may
be a convenient thing to do, but you'd better keep it low, because
a class so derived would not be safe for general-purpose use.
So then, what about inheriting from a patched string class:
#include <string>
class inheritable_string : public std::string {
public:
inheritable_string ( void ) :
std::string ()
{}
template < typename A >
inheritable_string ( A a ) :
std::string ( a )
{}
template < typename A, typename B >
inheritable_string ( A a, B b ) :
std::string ( a, b )
{}
template < typename A, typename B, typename C >
inheritable_string ( A a, B b, C c ) :
std::string ( a, b, c )
{}
template < typename A, typename B, typename C,
typename D >
inheritable_string ( A a, B b, C c, D d ) :
std::string ( a, b, c, d )
{}
template < typename A, typename B, typename C,
typename D, typename E >
inheritable_string ( A a, B b, C c, D d, E e ) :
std::string ( a, b, c, d, e )
{}
template < typename A, typename B, typename C,
typename D, typename E, typename F >
inheritable_string ( A a, B b, C c, D d, E e, F f ) :
std::string ( a, b, c, d, e, f )
{}
virtual ~inheritable_string ( void ) {}
};
Would it be safe to inherit from here.
Also, if you tried to preserve all of the base class functionality,
you would have to redefine the constructors (they are plentiful).
Is something wrong with the use of templated constructors?
Best
Kai-Uwe Bux