   Extending the standard library?
  Good idea/bad idea? I want some custom functions for strings and file streams which aren't there already, so I was thinking of just inheriting out those classes. Would this work fine or is it not reccommended?   
Bad Idea!The standard library containers are not meant for inheiritance. In particular, they do not have virtual destructors, so they will not be destroyed correctly.   ;Quote:Original post by BigFreakGood idea/bad idea? I want some custom functions for strings and file streams which aren't there already, so I was thinking of just inheriting out those classes. Would this work fine or is it not reccommended?However you go about it, before you implement these functions yourself be sure to check out boost::filesystem and the boost string algorithms and parsers; it's at least a possibility that what you're looking for already exists in these libraries.If you do end up implementing the functions yourself, consider making them non-member functions (which, among other things, will avoid the inheritance problem).   ;  Boost does seem to help a lot. Thanks :>   ;  Ok, so it's a bad idea because the dtor is not declared virtual ... but what other reasons are there. I ask out of curiosity and because i could* always do this:template <typename _Ty, typename _Ax = std::allocator<_Ty> >class MyWayMoreAwesomeVector: public std::vector<_Ty, _Ax>{public:typedef std::vector<_Ty, _Ax> parent;~MyWayMoreAwesomeVector(){parent::~vector();}};;  Well, for a start, if you were pointing at your derived vector through a standard vector pointer when you deleted it, your derived destructor would not get called so any custom deallocation etc you were doing would be bypassed.Containment is normally a better way to extend the standard library classes rather than inheritance.[EDIT] Enigma has just pointed out a far more serious issue that I am ashamed to say I totally missed as well.[Edited by - EasilyConfused on August 11, 2006 8:10:27 AM];  AP:  That code doesn't fix anything.  In fact it breaks it further.  As EasilyConfused has already pointed out, in the original problem case - deleting a derived class via a pointer-to-base - you still have the same problem.  In addition now any time a derived class is properly destructed it calls the base class destructor twice, which is undefined behaviour.Σnigma   