I have this class:
class stringlist {
public:
    typedef std::string str;
    void push(str);
    void pop();
    void print();
    void resize(size_t);
    size_t capacity();
    size_t size();
    stringlist() : N(15) {}
    stringlist(size_t sz) : N(sz) {}
private:
    size_t N;
    str* container = new str[N];
};
The following is a test program to test out the class:
stringlist slist(16);
slist.push("One");
slist.push("Two");
slist.push("Three");
std::cout << "Capacity: " << slist.capacity() << std::endl;
std::cout << "List size: " << slist.size() << std::endl;
slist.print();
I am not sure when and how the dynamically managed memory should be deleted. Would I need to call a destructor, ~stringlist() { delete [] container; }? Since new is used to create a data member, I am not sure if I am allowed to delete the member.
 
     
     
    