注意注释
1、首先明确类中的成员变量和成员函数
#ifndef _STUDENT_H
#define _STUDENT_H
class Student
{
private:
char m_name[20]; //学生的名字
int m_age; //学生年龄
char m_sex; //学生性别
Student *next; //在类中定义一个结构指针
public:
Student(char *n = "xxx",int a = 20,char s = 'm'); //构造函数 初始化信息
void print(); //输出信息
void SetNext(Student *s); //设置结点
Student *GetNext(); //指向下个结点
};
#endif
2、根据类中的数据来编写成员函数
Student::Student(char *n,int a,char s)
{
cout<< "Student constructor" <<endl;
strcpy (m_name , n);
m_age = a;
m_sex = s;
next = NULL;
}
void Student::print() //输出信息
{
cout<< m_name << " " << m_age <