35 lines
552 B
C++
35 lines
552 B
C++
|
//Stack.h
|
||
|
|
||
|
#ifndef STACK_H
|
||
|
#define STACK_H
|
||
|
|
||
|
const int DELTA = 5 ; // default growing size
|
||
|
class Stack {
|
||
|
// Interface
|
||
|
public:
|
||
|
Stack() { init( DELTA ); }
|
||
|
Stack( int in_size ) { init(in_size); }
|
||
|
~Stack() {
|
||
|
delete[] s;
|
||
|
}
|
||
|
int nitems() { return count ; }
|
||
|
bool full() { return (count==bufsize) ; }
|
||
|
bool empty() { return (count==0) ; }
|
||
|
|
||
|
void push( double c );
|
||
|
double pop();
|
||
|
void inspect();
|
||
|
|
||
|
void grow( int delta );
|
||
|
|
||
|
// Implementation
|
||
|
private:
|
||
|
void init( int in_size );
|
||
|
|
||
|
double* s ;
|
||
|
int count ;
|
||
|
int bufsize ;
|
||
|
|
||
|
};
|
||
|
#endif
|