有三个文件:
student.h文件
#include <string>
#include <iostream>
using namespace std;
const int MAX_NAME_SIZE = 30;
class Student{
public:
Student(const char * pszName);
~Student();
public:
static void PrintfAllStudents();
private:
char m_name[MAX_NAME_SIZE];
Student *next;
Student *prev;
static Student *m_head; //这里为什么后面没看到它的初始化语句??
};
function.cc文件
#include <iostream>
#include <string>
#include <string.h>
#include "student.h"
using namespace std;
Student::Student(const char *pszName)
{
strcpy(this->m_name,pszName);
this -> next = m_head;
this -> prev =NULL;
if(m_head != NULL)
m_head -> prev = this;