STL的继承
网上的观点都不赞成继承STL. SO上的一篇问答: Is it okay to inherit implementation from STL containers, rather than delegate? The risk is deallocating through a pointer to the base class ( delete , delete[] , and potentially other deallocation methods). Since these classes ( deque , map , string , etc.) don't have virtual dtors, it's impossible to clean them up properly with only a pointer to those classes: struct BadExample : vector<int> {}; int main() { vector<int>* p = new BadExample(); delete p; // this is Undefined Behavior return 0; } That said, if you're willing to make sure you never accidentally do this,