c++链表不打印数据

为什么这个链表不打印东西啊,救命啊
`

#include
using namespace std;


class list
{
private:
    int data;
    list* next_node;

    using lp = list*;


private:
    lp head;
    lp end;
public:
    list()
    {
        this->head;
        //head->next_node = NULL;
        this->end = NULL;
        head = end;//此时头节点指向尾结点,此时靠头节点来查询他的数据域就是空
    }


public:
    void print();
    void insert(int a);
};

void list::print()
{
    lp cur = this->head;
    while (cur != NULL)
    {
        cout << cur->data << "->" << endl;
        cur = cur->next_node;
        //cur在这个时候创建了新的结点
    }

};




void list::insert(int a)
{
    lp newnode;
    newnode = new list;
    if (this->head == NULL)
    {
        this->head = newnode;
    }
    else
    {
        lp tempt = this->head;
        while (tempt->next_node != NULL)
        {
            tempt = tempt->next_node;
        }
        tempt = newnode;
    }

}

void test()
{
    list p;
    p.insert(4);
    p.insert(8);
    p.insert(1);
    p.insert(3);
    p.insert(5);
    p.print();
}


int main()
{
    system("pause");
    return 0;
}

test函数都没调用

函数定义了得调用才行,程序从main函数开始执行,你main函数没有调用test函数,test函数就没有被执行

img


这次是只会打印一个0好奇怪啊