// A Stack for ints
class Stack2
{
private:
int *items_;
int count_;
public:
Stack2(int capacity) : items_(new int[capacity]), count_(0) {}
~Stack2() { delete[] items_; }
void Push(int item) { items_[count_++] = item; }
int Pop(void) { return items_[--count_]; }
bool IsEmpty(void) { return (count_ == 0); }
};
// A Stack for doubles
class Stack2
{
private:
double *items_;
int count_;
public:
Stack2(int capacity) : items_(new double[capacity]), count_(0) {}
~Stack2() { delete[] items_; }
void Push(double item) { items_[count_++] = item; }
double Pop(void) { return items_[--count_]; }
bool IsEmpty(void) { return (count_ == 0); }
};
// A Stack for char *
class Stack2
{
private:
char **items_;
int count_;
public:
Stack2(int capacity) : items_(new char *[capacity]), count_(0) {}
~Stack2() { delete[] items_; }
void Push(char * item) { items_[count_++] = item; }
char * Pop(void) { return items_[--count_]; }
bool IsEmpty(void) { return (count_ == 0); }
};
// A Stack for StopWatches
class Stack2
{
private:
StopWatch *items_;
int count_;
public:
Stack2(int capacity) : items_(new StopWatch[capacity]), count_(0) {}
~Stack2() { delete[] items_; }
void Push(StopWatch item) { items_[count_++] = item; }
StopWatch Pop(void) { return items_[--count_]; }
bool IsEmpty(void) { return (count_ == 0); }
};