0
void IntList::push_front(int value){
IntNode *holder = new IntNode(value);
holder -> next = head;
head = holder;
if(head == 0){
tail = head;
}
tail = holder;
}
#ifndef INTLIST_H
#define INTLIST_H
struct IntNode{
int data;
IntNode *next;
IntNode(int data) : data(data), next(0) {}
};
class IntList{
private:
IntNode *head;
IntNode *tail;
public:
void push_front(int value);
};
#endif
我如何在最後的尾節點獲得尾巴呢?我有if語句,所以如果列表爲空,它將被設置爲0。上述