记得以前学到生命周期这块时,一直想看看能不能用到写链表上,但面前一直有生命周期挡着我 ,学艺不精,我想白嫖,奈何百度里也没资料
struct __list_node
{
int value;
struct __list_node * next;
};
class list
{
private:
__list_node * head;
__list_node * tail;
int size;
public:
list();
void push_back(int value);
};
list::list()
{
head = tail = new __list_node(0,nullptr);
size = 0;
}
void list::push_back(int value)
{
auto new_elmt = new __list_node(value,nullptr);
tail = tail->next = new_elmt;
size ++;
}