cpp3_mult_f07 - CGS-2425 C+ EXAM 3, TEST FORM CODE "A",...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
This exam is OPEN BOOK, OPEN NOTES, CLOSED NEIGHBOR. Cheaters will receive a ZERO on the exam. Assume iostream and cmath have been included prior to any partial C++ code. The following class implements a data structure called stack that holds integers. Stack is variable in size. It can expand or shrink. You can "push" (insert) numbers in it and you can "pop" numbers out of it. Every time a push is performed, the size of the stack will increase. Every time a pop is performed, the stack size will decrease. The examples below show two stacks. The pointer (ptr) contains the address of the stack. Example 1 Example 2 _____ ptr -> |__4__| |__6__| |__8__| |__2 _| |__1__| top = 5 _____ ptr -> |__4__| |__6__| |__8__| top = 3 The next 4 questions refer to this Stack class. class Stack{ private: int *ptr; int top; public: Stack( ); ~Stack(void); void push(int); int pop(void); bool isEmpty(void); }; Stack::Stack(){ top = 0; } Stack::~Stack() {if (top>0) delete []ptr;}
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 6

cpp3_mult_f07 - CGS-2425 C+ EXAM 3, TEST FORM CODE "A",...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online