help me

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class object {
public:
virtual ~object() = 0;
};
inline object::~object() {}

class stack {
struct Link {
object *data;
Link *next;
Link(object* o, Link* n): data(o), next(n) {}
} *top;
public:
stack(): top(0) {}
~stack() {
while(top)
delete pop();
}
void push(object* o) {
top = new Link(o, top);
}
object *pop() {
if (top == 0) return 0;
object *tmp = top->data;    
Link *l = top;              
top = top->next;                    
delete l;
return tmp;
}
};

i think the bold code does :
create a pointer to class object and share with object data same adress in memory.
create a pointer to class link share with object top the same adress in memory.
assing to object top the adress memory of object next .
detele pointer l
return tmp wich is pointing to same class object?
what is object *pop really doing after all this ?
thank you.
Topic archived. No new replies allowed.