27 lines
469 B
C++
27 lines
469 B
C++
|
//Stack.cc
|
||
|
#include <iostream>
|
||
|
#include "Stack.hh"
|
||
|
|
||
|
void Stack::push(double c) {
|
||
|
if (full()) {
|
||
|
std::cout << "Stack::push() Error: stack is full" << std::endl ;
|
||
|
return ;
|
||
|
}
|
||
|
s[count++] = c ;
|
||
|
}
|
||
|
|
||
|
double Stack::pop() {
|
||
|
if (empty()) {
|
||
|
std::cout << "Stack::pop() Error: stack is empty" << std::endl ;
|
||
|
return 0 ;
|
||
|
}
|
||
|
return s[--count] ;
|
||
|
}
|
||
|
|
||
|
void Stack::inspect() {
|
||
|
for ( int i = nitems() - 1; i >= 0; i-- )
|
||
|
{
|
||
|
std::cout << i << ": " << s[i] << std::endl;
|
||
|
}
|
||
|
}
|