class StapelListe {
public:
StapelListe(void);
~StapelListe();
void cm_push(itemType wert);
itemType cm_pop();
int cm_empty() {
return head->next == z;
}
private:
node *head, *z;
};
StapelListe::StapelListe(void) {
head = new node;
z = new node;
head->next = z;
z->next = z;
}
StapelListe::~StapelListe() {
node *k = head;
while(k != z) {
head = k;
k = k->next;
delete head;
}
}
void StapelListe::cm_push(itemType wert) {
node *k = new node;
k->key = wert;
k->next = head->next;
head->next = k;
}
itemType StapelListe::cm_pop() {
itemType x;
node *k = head->next;
head->next = k->next;
x = k->key;
delete k;
return x;
}
|