Why OOP?
#define MAX 100
typedef struct {
int top;
int val[MAX];
} STACK
typedef STACK *STACK_PTR;
void init(STACK_PTR sp);
void push(STACK_PTR sp, int x);
int pop(STACK_PTR sp);
int isEmpty(STACK_PTR sp);
What are the problems?
Still not generic
What happens if a stack of another type is needed?
Fixed size
No effective information hiding
Previous slide
Next slide
Back to first slide
View graphic version