To answer your real question: declaring a function in a class hides all inherited functions with the same name in this class. In other words, since ValVector has a function called insert , the inherited std::vector::insert no longer appears in it. Probably the best way to solve this problem is to bring the inherited insert back into scope with the using declaration:
template<class T, class Allocator = allocator<T>> class ValVector : public std::vector<T, Allocator> { public: using std::vector<T, Allocator>::insert; BOOL insert(const T& elem) { return (this->insert(this->end(),elem)!=this->end()); } };
However, I have a comment. I think your approach is wrong. std containers are not intended for public inheritance; if nothing else, they have no virtual destructor and no protected members. You will be better off providing a free function that can then be used with any std::vector , and not just your type:
template <class T, class A> BOOL insert(std::vector<T, A> &vec, const T &val) { return vec.insert(vec.end(), val) != vec.end(); }
Or make it more versatile for working with any container:
temlate <class C, class E> BOOL insert(C &cont, const E &val) { return cont.insert(cont.end(), val) != cont.end(); }
Angew source share