用类建立链表出现的问题,求解各位高手?
#include <iostream>using namespace std;
class list{
public:
int data;
list *next;
list(){}
~list(){}
static list L[100];
int length;
};
void creat();
void insert();
void deletelist();
void print();
void creat()
{
int n;
int a;
cin>>a;//输入头结点的数据
list::L[0].data=a;
cin>>n;//输入要创建节点的个数
list::length=n;
for(int i=0;i<n;i++)
{
int b[100];
list::L[i].next=list::L[i+1];
cin>>b[i];
list::L[i+1].data=b[i];
}
}
void print()
{
for(int i=0;i<list::length;i++)
{
cout<<list::L[i].data<<endl;
}
}
void main()
{
creat();
print();
}
Compiling...
noname0.cpp
C:\Documents and Settings\魅力元素-Au\Local Settings\Temp\temp232\noname0.cpp(24) : error C2597: illegal reference to data member 'list::length' in a static member function
C:\Documents and Settings\魅力元素-Au\Local Settings\Temp\temp232\noname0.cpp(28) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class list' (or there is no acceptable conversion)
C:\Documents and Settings\魅力元素-Au\Local Settings\Temp\temp232\noname0.cpp(37) : error C2597: illegal reference to data member 'list::length' in a static member function
C:\Documents and Settings\魅力元素-Au\Local Settings\Temp\temp232\noname0.cpp(37) : error C2568: '<' : unable to resolve function overload
Error executing cl.exe.
请问这是什么错误,不懂改啊,请教高手