1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/Stack/Stack.hh
2019-12-12 17:22:39 +01:00

54 lines
912 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(const Stack& other) {
// Use init to set all vars naturally
init( other.bufsize ) ;
if ( s == other.s )
{
std::cout << "sAmE" << std::endl;
}
// Then update the count as this is dependant on the copied Stack
count = other.count ;
// Copy elements
for ( int i=0 ; i < bufsize ; i++ ) {
s[i] = other.s[i] ;
}
}
~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