Homework Solution 2: stack.h
// This solution represents the stack with a linked list.
// “item” is a simple data structure used to construct
// the linked list.
struct item {
int data;
item *next;
};
class stack {
private:
item *data_list;
int count_items(item *list); // Private utility function
public:
stack();
~stack();
int size();
void push(int i);
int pop();
};
Previous slide
Next slide
Back to first slide
View graphic version