void EventsStack::push(Event *e){
EventNode *q = new EventNode();
q->data = e;
q->next = _top;
_top = q;
}
void main() {
EventsStack eventStack;
Event e1(1);
eventStack.push(&e1);
Event e2(2);
eventStack.push(&e2);
}
第一个问题:我什么时候做
eventStack.push(&e1);
我是否将 e1 的地址发送到 push 函数,而 push 函数将其作为指针接收?好像我在做:
Event *e = 1000 (1000 is the offset (address) of e1 for example on the stack)
?
第二个问题:我被要求在运行 main 函数时说明堆栈。当我到达线路时
eventStack.push(&e1);
是否将 4 字节返回地址和指向 e1 的 4 字节指针分配为函数的激活帧,或者在这种情况下没有激活帧,因为 eventStack 是 EventsStack 类的对象,并且 push 是其成员函数之一?