class Faculty : public Member

{

private :

int major;

int degree;

Faculty* next; 

public :

Faculty(string id, string name, string department, int major, int degree) : Member(id, name, department)

{

this->major = major;

this->degree = degree;

next = NULL;

}

~Faculty(){}


void setMajor(int major){this->major = major;}

void setDegree(int degree){this->degree = degree;}

void setNext(Faculty* fac){this->next = fac;}


int getMajor(){return major;}

int getDegree(){return degree;}

Faculty* Next(){return next;}

};



ioHandler.h


Faculty* head = new Faculty(id,name,department,major,degree);

Faculty* tail = head;

while (!file.eof())

{

file >>id>>name>>department>>major>>degree;

tail = tail->Next();

tail = new Faculty(id,name,department,major,degree);

}


tail에 head를 넣고 tail next로 간 다음 new로 받게 했는데 잘안되더라구요

그래서 밑의 소스로 바꿨는데 잘 되요....

제 생각엔 그냥 순서만 바꾼거 같은데..

위의 소스에서는 안됐던 이유가 뭐죠?


while (!file.eof())

{

file >>id>>name>>department>>major>>degree;

tail->setNext(new Faculty(id,name,department,major,degree));

tail = tail->Next();

}