
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solution for quiz #2 of the cs2143-2144 data structures course, focusing on the line-by-line explanation of the stack class definition. It highlights potential issues and offers corrections.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

class stack { protected: int *ptr; unsigned int size ; unsigned int top; public: stack(unsigned S) { ptr= new int[S]; top=0; size=S; } int push(int value) { if (top>=s) { cout<<"FALSE"; return 0; } else{ ptr[top]=value; top++; } } int pop() { if (top==0) { cout<<"CANT GET THE VALUES"; return 0; } else { int C; val=ptr[top]; --top; return C; } } };