Why OOP?
What are the problems?
Not generic
What happens if more stacks are needed?
What happens if a stack of a different type is needed?
Fixed size
No effective information hiding mechanism
double stack[100];
int top;
void init(){
top = -1;
}
void push(int val){
if (!isFull()){
stack[++top] = val;
else error(“stack is full”);
}
...
Previous slide
Next slide
Back to first slide
View graphic version