Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

What's wrong with this

Name: Anonymous 2009-07-02 18:18

OK I have this very simple stack class. However when I try to instantiate an object of type Stack, the whole program just hangs. What's trong?

template <class T>
class Stack {
    T *arr;
    int n;
    int ptr;
public:
    class Stack_voll{};
    class Stack_leer{};

    Stack(int size) : ptr(0), n(size), arr(new int[n]) {}

    void push(const T& e) {
        if(ptr >= n)
            throw Stack_voll();
        arr[ptr++] = e;
    }

    T& pop() {
        if(ptr == 0)
            throw Stack_leer();
        ptr--;
        return arr[ptr];
    }
};

Name: Anonymous 2009-07-02 18:34

Trongs are gripping and lifting tools which are made up of three limbs or finger-channels, each with teeth on the end of them. They are generally made of polypropylene and are dishwasher safe. Trongs are designed for eating finger food such as buffalo wings and bbq ribs so that the user doesn't get their fingers messy. They are used pairs so that the user has one for each hand. Trongs stand on the table like a tripod and the user is able to lift them by applying a slight inward pressure.

Name: Anonymous 2009-07-02 18:38

IHBT
I'll help you on condition you promise not to come back here ever again, and you insure to sage.

Name: Anonymous 2009-07-02 18:44

No [code] tags; also, Sepples.

Name: Anonymous 2009-07-02 20:55

1c1
< Stack(int size) : ptr(0), n(size), arr(new int[n]) {}
---
Stack(int size) : ptr(0), n(size), arr(new T*[n]) {}

Name: Anonymous 2010-11-26 21:03


Don't change these.
Name: Email:
Entire Thread Thread List