Here is the original requirements:
Write a class template for a linked-list implementation of a stack. The stack class must have the push, pop and isEmpty functions included, but with four additional functions: de- structor, copy constructor, overloaded assignment operator, and deepCopy. The private section shall only have one data member: a pointer called top. Be sure to have the pointer of the last node (at the bottom of the stack) set to NULL at all times. (This condition was- n’t necessary in the linked-list implementation of the queue, because the back pointer signified the last node—but it is generally necessary in linked lists). At the top of the class implementation file, include iostream (important because NULL is defined here) and use the std namespace.
Because my prof always don't talk much in the class, now I'm kind of confused with this project. I've made the push pop and isEmpty, although I'm not sure is it correct. But I've no idea how to make those four additional functions. Please give me some help; Here is the code I've done so far.
You might want to try this as a test case for your code.
1 2 3 4 5
int main()
{
Stack s;
int val = s.pop();
}
By the way, you were instructed to create a class template for your stack. That would allow you to have a stack of ints, doubles, strings, doohickeys and whatchamacallits without changing your code. You have a stack that contains ints.
Do you need help with template classes, or are you doing initial development with ints and planning to generalize when you have it all working?