My professor is known for his vagueness in assignment instructions. He wants us to create two template classes in c++ using pointer type private members as an array and then removing objects of that array, adding things to the array, etc.. However, isn't it impossible to initialize the pointer array to the correct size without somehow getting an input from the console or the program to determine how many pointers to create? I would email him and ask but he has become sick and his email response time has slowed to something like 2 days. Here is one of the two classes we are given :
template<class T>
class Stack{
private:
T* StackArray;
public:
Stack();
~Stack();
void push(const T&); //pushes a data at the top
T pop(); //deletes data from the top and returns the data
bool isEmpty();//checks if the stack is empty
T top();//returns the top of the stack
};
I have researched to see if there was a function like get.length() that could be applied but I couldn't find anything. This isn't an array type so I can't use the functions I found. Is the only way this class will work if I also take a size input from the user? Thanks in advance.