pushing and popping at an index does not a stack make.
what the heck is freestack() and reallok()?
Here are the signatures of the functions you need to implement:
Code:
Stack(); // should initialize a pointer, and the value of size
~Stack(); // pops until empty
void push(int); // adds *something* to the top, move pointers around
void pop(); // takes no argument, removes the top, move pointers around
int top(); // returns the int at the top of the stack
int size(); // returns the value of size
bool empty(); // returns true of false (hint: use size)
EDIT: Here's a few more hints to save time:
The private members stack needs:
Code:
Node* top;
int size;
// ... And a node struct...
struct
{
int data;
Node* next;
};
I leave the rest to you