GSXdan
12-07-2003, 08:50 PM
assuming:
class Node {
public:
Node( char = ' ') { data = value;, next = 0}
char data;
Node * next;
};
class stack {
public:
stack();
void push( char let );
char pop();
bool empty();
private:
Node * top;
};
would this pop function work(no need to compile it or anything, i just need to write it out)?:
char stack:: pop() {
char temp;
temp = (top->next)->data;
top-> = (top->next)->next; // not sure about this part
return temp;
}
seems a little too simple, but i guess there isnt too much involved.
TIA ^ dan
class Node {
public:
Node( char = ' ') { data = value;, next = 0}
char data;
Node * next;
};
class stack {
public:
stack();
void push( char let );
char pop();
bool empty();
private:
Node * top;
};
would this pop function work(no need to compile it or anything, i just need to write it out)?:
char stack:: pop() {
char temp;
temp = (top->next)->data;
top-> = (top->next)->next; // not sure about this part
return temp;
}
seems a little too simple, but i guess there isnt too much involved.
TIA ^ dan