I understand that it is bad practice to inherit from a STL container, but my assignments requires that I use inheritence instead of composition. I have to "inherit from std::vector and you need to choose whether public or private inheritance is the best choice." I am to support the following operations with the given signatures. I am using private inheritence, but I am having trouble with my .cpp file on how I use the vector STL container to implement these functions. I am used to using composition.
#ifndef STACK_H
#define STACK_H
#include <vector>
#include <stdexcept>
// Use inheritance from std::vector (choose public/private) as appropriate
template <typename T>
class Stack : private std::vector<T>
{
public:
Stack();
~Stack();
bool empty() const;
size_t size() const;
void push(const T& item);
void pop(); // throws std::underflow_error if empty
const T& top() const; // throws std::underflow_error if empty
// Add other members only if necessary
};