I have a question concerning making a class "my_vector<...>" that is a subclass of "std::vector<...>". Is it possible to make only one member from the std::vector<...> visable in the global scope but all funcionality visable in the scope of"my_vector<...>".
For example:
template<typename T>
class my_vector : protected std::vector<T>
{
// room for constructors...
// making "reference operator [] ( size_type n );"
// visable in the global scope with out copying code...
// room for new functionality...
};
or
template<typename T>
const class my_vector : public std::vector<T>
{
// room for constructors...
// making "reference operator [] ( size_type n );"
// the only member to dissregard the const declaration and be able to change
// specific elements
// room for new functionality...
};
//The last example was not exactly was I was asking but if it works it is sufficient for my task.
I know that one possible way is to overload all other members and make them private, Is it the only way, or can anyone come up with a better approach?
No, you should make a class that contains an instance of the STL container and provides whatever
API methods you want. You can do this either by using the "using" class as Bazzy's example shows
or write simple one-liner inlined forwarder functions.