Demo entry 6775409

TTTT

   

Submitted by anonymous on Nov 24, 2018 at 03:58
Language: C++. Code size: 659 Bytes.

#include <iostream>
#include <string.h>
using namespace std;

template<class T>
class stack
{
public:
    virtual ~stack() {}
    virtual bool empty() const = 0;
    virtual int size() const = 0;
    virtual T& top() = 0;
    virtual void pop() = 0;
    virtual void push(const T& theElement) = 0;
};

template<class T>
class ArrayStack : public stack<T>
{
public:
    ArrayStack(int initialCapacity = 10)
    {
        index = 0;
        elements = new T[initialCapacity];
    }

    ~ArrayStack() {~index; delete [] elements;}

    bool empty() const {return index==0;}

    int size() const {return index;}

    T& top()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).