Coursework for the Master's course Computational Data Science: Advanced Programming
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

54 lines
912 B

//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