#include
#include
using namespace std;
typedef struct student
{
char name[20];
char num[20];
struct student *next;
}Lnode,*linklist;
class Class
{public:
Lnode *head;
static int stunum;
static void printfstunum();
Class()
{
head=(linklist)malloc(sizeof(Lnode));
head->next=NULL;
Lnode *p=head->next;
cout<<"请输入姓名与学号"<>p->name>>p->num;
}
void insertstu(Lnode *head)
{ Lnode *p;
p=head->next;
while(p!=NULL)
{
p=p->next;
}
if(p==NULL)
{
cout<<"请输入学生信息"<>p->name>>p->num;
}
}
void showstu(Lnode *head)
{
Lnode *p=head->next;
while(p!=NULL)
{
cout<name<<","<num<next;
}
}
};
int Class::stunum=20;
int main()
{ Class a;
Lnode *headstu;
headstu=(linklist)malloc(sizeof(Lnode));
headstu->next=NULL;
headstu=a.head;
a.showstu(headstu);
a.printfstunum();
return 0;
}
void Class::printfstunum()
{
cout<<"班级人数为:"<
headstu=a.head;
你前面白给headstu分配内存了,这指针指向直接改了?