如何用C语言或C++实现一个List类?

来源:百度知道 编辑:UC知道 时间:2024/05/21 07:16:19
请帮忙一下

  1. C语言没有类的概念。C++有现成的List类, #include<list>即可。

  2. 如果要自己实现可以参考C++数据结构的书籍,是最基本的练习。

    这里实现一个简单的例程,请参考:

    #include <iostream>
    #include <fstream>
    #include <stdlib.h>
    #include <string.h>
    using namespace std;
    #include<stdio.h>
    #include<string>
     
    #include "math.h"
     
    template<class T> class List{
    public:
        List()  //构造函数
        {
            pFirst = NULL;
        }
         
        void Add(T& t)  //在Link表头添加新结点
        {
            if(pFirst == NULL)
            {<