unexpected end of file

i got an error call unexpected end of file. And i declare an object to one of my class one ? anyone knows what is the problem ?
Can you show your code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include <iostream.h>
#include <string.h>
#include<fstream.h>
#include< stdlib.h > 

class unimas
{
public:
	unimas() {}
	~unimas() {}
    char* GetName() {return Name;}
	void SetName(char name) {Name[51]=name;}
	char* GetId() {return Id;}
	void SetId(char id) {Id[11]=id;}
	char* GetNation() { return Nation;}
	void SetNation(char nation) { Nation[21]=nation;}
	char* GetAddress(){return Address;}
	void SetAddress(char address) {Address[101]=address;}
	

protected:

	char Nation[21];
	char Name[51];
	char Address[101];
	char Id[11];


};

class Student : public unimas
{
public:
	Student() {}
	~Student() {}
	char* GetDate() {return Date;}
	void SetDate(char date) { Date[11]=date;}
	char* GetFaculty() {return Faculty;}
	void SetFaculty(char faculty) {Faculty[6]=faculty;}
	char* GetYear() {return Year;}
	void SetYear(char year) {Year[6]=year;}
	char* GetGrades() {return Grades;}
	void SetGrades(char grades) {Grades[5]=grades;}
	char* GetSubTak() {return SubTak;}
	void SetSubTak(char subtak) {SubTak[101]=subtak;}
	char* GetSubToBeTak() {return SubToBeTak;)
	void SetSubToBeTak(char subtobetak) {SubToBeTak[101]=subtobetak;}
	
	bool Empty;

protected:

	char Date[11];
	char Faculty[6];
	char Year[6];
	char Grades[5];
	char SubTak[101];
	char SubToBeTak[101];

};

Student S[1000];
int NumberofStudent;

void InitializeStudent()
{
	
	for(int i=0;i<100;++i)
	{   
		S[i].Empty = true;
	}
	NumberofStudent = 0;
}

bool OpenStudentRecord()
{
	InitializeStudent();
	ifstream iS;
	iS.clear();
	iS.open("./debug/Student.dat",ios::in);
	if(!iS) return false;
	int NumFields = 0;
	while(!iS.eof())
	{   
		if(NumFields == 10) 
		{
			S[NumberofStudent].Empty = false;
			++NumberofStudent;
			NumFields = 0;
		}
		if(NumFields == 0)
		{	
			iS.getline(S[NumberofStudent].GetName(),51,';'); 
			++NumFields;
		}
		else if(NumFields == 1)
		{	
			iS.getline(S[NumberofStudent].GetId(),11,';'); 
			++NumFields; 
		}
		else if(NumFields == 2)
		{	
			iS.getline(S[NumberofStudent].GetNation(),21,';');
			++NumFields; 
		}	
		
		else if(NumFields == 3)
		{	
			iS.getline(S[NumberofStudent].GetAddress(),101,';');
			++NumFields; 
		}	
		else if(NumFields == 4)
		{	
			iS.getline(S[NumberofStudent].GetDate(),11,';');
			++NumFields; 
		}
		else if(NumFields == 5)
		{	
			iS.getline(S[NumberofStudent].GetFaculty(),6,';');
			++NumFields; 
		}
		else if(NumFields == 6)
		{	
			iS.getline(S[NumberofStudent].GetYear(),6,';');
			++NumFields; 
		}
		else if(NumFields == 7)
		{	
			iS.getline(S[NumberofStudent].Getgrades(),5,';');
			++NumFields; 
		}
		else if(NumFields == 8)
		{	
			iS.getline(S[NumberofStudent].GetSubTak(),101,';');
			++NumFields; 
		}	
		else if(NumFields == 9)
		{	
			iS.getline(S[NumberofStudent].GetSubToBeTak(),101,';');
			++NumFields; 
		}					
		
	}
	iS.close();
	return true;
}

bool SaveStudentRecord()
{
	ofstream oS("./debug/Student.dat",ofstream::out | ofstream::trunc );
	if(!oS) return false;
	for(int j=0;j<NumberofStudent;++j)
	{	
		if(S[j].Empty == false)
		{
			oS.write(S[j].GetName(),strlen(S[j].GetName()));
			oS.write(";",1);
			oS.write(S[j].GetId(),strlen(S[j].GetId()));
			oS.write(";",1);
			oS.write(S[j].GetNation(),strlen(S[j].GetNation()));
			oS.write(";",1);
			oS.write(S[j].GetAddress(),strlen(S[j].GetAddress()));
			oS.write(";",1);
			oS.write(S[j].GetDate(),strlen(S[j].GetDate()));
			oS.write(";",1);
			oS.write(S[j].GetFaculty(),strlen(S[j].GetFaculty()));
			oS.write(";",1);
			oS.write(S[j].GetYear(),strlen(S[j].GetYear()));
			oS.write(";",1);
			oS.write(S[j].GetGrades(),strlen(S[j].GetGrades()));
			oS.write(";",1);
			oS.write(S[j].GetSubTak(),strlen(S[j].GetSubTak()));
			oS.write(";",1);
			oS.write(S[j].GetSubToBeTak(),strlen(S[j].GetSubToBeTak()));
			oS.write(";",1);

			
		}
	}
	oS.close();
	return true;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
char menu[10];
bool StudentMenu()
{  
	
	system ("CLS");
	int j;	
	cout<<"**********************************\n";
	cout<<"********** Student Menu **********\n";
	cout<<"1. Add New Student Data\n";
	cout<<"2. List Student\n";
	cout<<"3. Change Student Information\n";
	cout<<"4. Delete Student\n";
	cout<<"5. Save Student\n";
	cout<<"6. Main Menu\n";
	cout<<"Number of Student = "<<NumberofStudent<<endl;
	cout<<"Please enter your choice: ";
	cin.getline(menu,10);
	if(menu[0] == '1')
	{  
		system ("CLS");
	   cout<<"Name : ";
	   cin.getline(S[NumberofStudent].GetName(),51);

	   cout<<"ID/Matrix no.  : ";
	   cin.getline(S[NumberofStudent].GetId(),11);

	   cout<<"Nationality : ";
	   cin.getline(S[NumberofStudent].GetNation(),21);

	   cout<<"Address : ";
	   cin.getline(S[NumberofStudent].GetAddress(),101);

	   cout<<"Date of registration (eg. 01/07/2009) : "; 
	   cin.getline(S[NumberofStudent].GetDate(),11);

	   cout<<"Falculty (eg. FK) : ";
	   cin.getline(S[NumberofStudent].GetFaculty(),6); 
	   
	   cout<<"Year (eg. 08/09) : ";
	   cin.getline(S[NumberofStudent].GetYear(),6); 
	   
	   cout<<"Grades/CGPA : ";
	   cin.getline(S[NumberofStudent].GetGrades(),5);
	   
	   cout<<"Subjects taken : ";
	   cin.getline(S[NumberofStudent].GetSubTak(),101); 
	  
	   cout<<"Subjects to be taken : ";
	   cin.getline(S[NumberofStudent].GetSubTobeTak(),101);

	   S[NumberofStudent].Empty = false;
	   ++NumberofStudent;
	   return true;
	}
	else if(menu[0] == '2')
	{	
		system ("CLS");
		for(int k=0;k<NumberofStudent;++k)
		{	
			cout<<"Record "<<k+1<<"\n";
		    	cout<<"Name : "<<S[k].GetName()<<"\n";
			cout<<"ID/Matrix no.  : "<<S[k].GetId()<<"\n";
			cout<<"Nationality : "<<S[k].GetNation()<<"\n";
			cout<<"Address : "<<S[k].GetAddress()<<"\n";
			cout<<"Date of registration : "<<S[k].GetDate()<<"\n";
			cout<<"Falculty : "<<S[k].GetFaculty()<<"\n";
			cout<<"Year : "<<S[k].GetYear()<<"\n";
			cout<<"Grades/CGPA : "<<S[k].GetGrades()<<"\n";
			cout<<"Subjects taken : "<<S[k].GetSubTak()<<"\n";
			cout<<"Subjects to be taken : "<<S[k].GetSubToBeTak()<<"\n";

  	        cout<<"Press 'enter' for next record"<<endl;
			cin.get();
		}
		cout<<"No more Student Record!"<<endl;
		return true;
	}
	else if(menu[0] == '3')
	{	
		system ("CLS");
		cout<<"Please enter the Student ID/Matrix no. to change information : ";
		cin.getline(menu,10);
		for(j=0;j<NumberofStudent;++j)
		{	
			if(strcmp(menu,S[j].GetId()) == 0)
			{  
				cout<<"Please key in student new data."<<endl;
				cout<<"Name ("<<S[j].GetName()<<") :";
				cin.getline(S[j].GetName(),51);
				cout<<"Nationality ("<<S[j].GetNation()<<") :";
				cin.getline(S[j].GetNation(),21);
				cout<<"Address ("<<S[j].GetAddress() <<") :";
				cin.getline(S[j].GetAddress(),101);
				cout<<"Date of registration ("<<S[j].GetDate() <<") :";
				cin.getline(S[j].GetDate(),11);
				cout<<"Faculty ("<<S[j].GetFaculty()<<") :";
				cin.getline(S[j].GetFaculty(),6);
				cout<<"Year ("<<S[j].GetYear()<<") :";
				cin.getline(S[j].GetYear(),6);
				cout<<"Grades/CGPA ("<<S[j].GetGrades()<<") :";
				cin.getline(S[j].GetGrades(),5);
				cout<<"Subjects taken ("<<S[j].GetSubTak()<<") :";
				cin.getline(S[j].GetSubTak(),101);
				cout<<"Subjects to be taken ("<<S[j].GetSubToBeTak()<<") :";
				cin.getline(S[j].GetSubToBeTak(),101);
			
				return true;
			}
		}
		cout<<"Student record not found!"<<endl;
		return true;
	}
	else if(menu[0] == '4')
	{   
		system ("CLS");
		cout<<"Please enter the Student ID/Matrix no. to Delete : ";
		cin.getline(menu,10);
		for(j=0;j<NumberofStudent;++j)
		{	
			if(strcmp(menu,S[j].GetId()) == 0)
			{   
				cout<<"Are you sure Delete the Student ("<<S[j].GetName()<<")? (y/n) : ";
				cin.getline(menu,10);
				if(menu[0] == 'y' || menu[0] == 'Y')
				{
					while(j+1<NumberofStudent)
					{  
						strcpy(S[j].GetId(),S[j+1].GetId());
						strcpy(S[j].GetName(),S[j+1].GetName());
						strcpy(S[j].GetNation(),S[j+1].GetNation());
						strcpy(S[j].GetAddress(),S[j+1].GetAddress());
						strcpy(S[j].GetDate(),S[j+1].GetDate());
						strcpy(S[j].GetFaculty(),S[j+1].GetFaculty());
						strcpy(S[j].GetYear(),S[j+1].GetYear());
						strcpy(S[j].GetGrades(),S[j+1].GetGrades());
						strcpy(S[j].GetSubTak(),S[j+1].GetSubTak());
					strcpy(S[j].GetSubToBeTak(),S[j+1].GetSubToBeTak());							
						++j;
					}
					S[j].Empty = true;
					--NumberofStudent;
				}
				return true;
			}
		}
		cout<<"Student record not found!"<<endl;
		return true;
	}
	else if(menu[0] == '5')
	{
		system ("CLS");
		SaveStudentRecord();
	    return true;
	}
	else if(menu[0] == '6')
		return false;
	else 
	{   
		system ("CLS");
		cout<<"Unknown Command. Please try again!\n";
	    return true;
	}
	return false;
}
class Staff:public unimas
{
public:
	Staff() {}
	~Staff() {}
	char* GetPost() {return Post;}
	void SetPost(char post) { Post[21]=post;}
	char* GetSalary() {return Salary;}
	void SetSalary(char salary) {Salary[11]=salary;}
	char* GetPaper() {return Paper;}
	void SetPaper(char peper) {Paper[101]=paper;}
	
	bool Empty; //is this record empty?

protected:

	char Post[21];
	char Salary[11];
	char Paper[101];

};

Staff B[1000];
int NumberofStaff;

void InitializeStaff()
{
	for(int i=0;i<1000;++i)
	{  
		B[i].Empty = true;
	}
	NumberofBook = 0;
}

bool OpenStaffRecord()
{
	InitializeStaff();
	ifstream iB;
	iB.clear();
	iB.open("./debug/Staff.dat",ios::in);
	if(!iB) return false;
	int NumFields = 0;
	while(!iB.eof())
	{   
		if(NumFields == 7) 
		{
			B[NumberofStaff].Empty = false;
			++NumberofStaff;
			NumFields = 0;
		}
		if(NumFields == 0)
		{	
			iB.getline(B[NumberofStaff].GetName(),51,';'); 
			++NumFields;
		}
		else if(NumFields == 1)
		{	
			iB.getline(B[NumberofStaff].GetId(),11,';'); 
			++NumFields; 
		}
		else if(NumFields == 2)
		{	
			iB.getline(B[NumberofStaff].GetNation(),21,';'); 
			++NumFields;
		}	
		else if(NumFields == 3)
		{	
			iB.getline(B[NumberofStaff].GetNation(),21,';'); 
			++NumFields;
		}
		else if(NumFields == 4)
		{	
			iB.getline(B[NumberofStaff].GetAddress(),101,';'); 
			++NumFields;
		}
		else if(NumFields == 5)
		{	
			iB.getline(B[NumberofStaff].GetPost(),21,';'); 
			++NumFields;
		}
		else if(NumFields == 6)
		{	
			iB.getline(B[NumberofStaff].GetSalary,11,';'); 
			++NumFields;
		}
		else if(NumFields == 7)
		{	
			iB.getline(B[NumberofStaff].GetPaper(),101,';'); 
			++NumFields;
		}							
	}
	iB.close();
	return true;
}
bool SaveStaffRecord()
{
	ofstream oB("./debug/Staff.dat",ofstream::out | ofstream::trunc );
	if(!oB) return false;
	for(int j=0;j<NumberofStaff;++j)
	{	if(B[j].Empty == false)
		{
			oB.write(B[j].GetId(),strlen(B[j].GetId()));
			oB.write(";",1);
			oB.write(B[j].GetName(),strlen(B[j].GetName()));
			oB.write(";",1);
			oB.write(B[j].GetNation(),strlen(B[j].GetNation()));
			oB.write(";",1);
			oB.write(B[j].GetAddress(),strlen(B[j].GetAddress()));
			oB.write(";",1);
			oB.write(B[j].GetPost(),strlen(B[j].GetPost()));
			oB.write(";",1);
			oB.write(B[j].GetSalary(),strlen(B[j].GetSalary()));
			oB.write(";",1);
		}
	}
	oB.close();
	return true;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
bool StaffMenu()
{  	
	system ("CLS");
	int j;
	cout<<"*******************************\n";
	cout<<"********** Staff Menu **********\n";
	cout<<"1. Add New Staff Data\n";
	cout<<"2. List Staff\n";
	cout<<"3. Change Staff Information\n";
	cout<<"4. Delete Staff\n";
	cout<<"5. Save Staff\n";
	cout<<"6. Main Menu\n";
	cout<<"Number of staff = "<<NumberofStaff<<endl;
	cout<<"Please enter your choice: ";
	cin.getline(menu,9);
	if(menu[0] == '1')
	{  
	   system ("CLS");
	    cout<<"Name : ";
	   cin.getline(S[NumberofStaff].GetName(),51);

	   cout<<"ID/Staff no.  : ";
	   cin.getline(S[NumberofStaff].GetId(),11);

	   cout<<"Nationality : ";
	   cin.getline(S[NumberofStaff].GetNation(),21);

	   cout<<"Address : ";
	   cin.getline(S[NumberofStaff].GetAddress(),101);
	   
	   cout<<"Post : ";
	   cin.getline(S[NumberofStaff].GetPost(),21);
	   
	   cout<<"Salary : RM ";
	   cin.getline(S[NumberofStaff].GetSalary(),11);
	   
	   cout<<"Paper Published (for acedemic) : ";
	   cin.getline(S[NumberofStaff].GetPaper(),101);

	   B[NumberofStaff].Empty = false;
	   ++NumberofStaff;
	   return true;
	}
	else if(menu[0] == '2')
	{	
		system ("CLS");
		for(int k=0;k<NumberofStaff;++k)
		{
			cout<<"Record "<<k+1<<"\n";
		    cout<<"Name : "<<B[k].GetName()<<"\n";
			cout<<"ID/Staff no.  : "<<B[k].GetId()<<"\n";
			cout<<"Nationality : "<<B[k].GetNation()<<"\n";
			cout<<"Address : "<<B[k].GetAddress()<<"\n";
			cout<<"Post : "<<B[k].GetPost()<<"\n";
			cout<<"Salary : RM "<<B[k].GetSalary()<<"\n";
			cout<<"Paper Published (for acedemic) : "<<B[k].GetAddress()<<"\n";

  	        cout<<"Press 'enter' for next record"<<endl;
			cin.get();
		}
		cout<<"No more Staff Record!\n";
		return true;
	}
	else if(menu[0] == '3')
	{	
		system ("CLS");
		cout<<"Please enter the Staff ID to change information : ";
		cin.getline(menu,10);
		for(j=0;j<NumberofStaff;++j)
		{	
			if(strcmp(menu,B[j].GetId()) == 0)
			{   
				cout<<"Please key in staff new data."<<endl;
				cout<<"Name ("<<B[j].GetName()<<") :";
				cin.getline(B[j].GetName(),51);
				cout<<"Nationality ("<<B[j].GetNation()<<") :";
				cin.getline(B[j].GetNation(),21);
				cout<<"Address ("<<B[j].GetAddress() <<") :";
				cin.getline(B[j].GetAddress(),101);
				cout<<"Post ("<<B[j].GetPost() <<") :";
				cin.getline(B[j].GetPost(),21);
				cout<<"Salary (RM "<<B[j].GetSalary() <<") :";
				cin.getline(B[j].GetSalary(),11);
				cout<<"Paper published ("<<B[j].GetPaper() <<") :";
				cin.getline(B[j].GetPaper(),101);

				return true;
			}
		}
		cout<<"Staff record not found!"<<endl;
		return true;
	}
	else if(menu[0] == '4')
	{   
		system ("CLS");
		cout<<"Please enter the Staff ID to Delete : ";
		cin.getline(menu,10);
		for(j=0;j<NumberofStaff;++j)
		{	
			if(strcmp(menu,B[j].GetId()) == 0)
			{   
				cout<<"Are you sure Delete the Staff ("<<B[j].GetName()<<")? (y/n) : ";
				cin.getline(menu,10);
				if(menu[0] == 'y' || menu[0] == 'Y')
				{
					while(j+1<NumberofStaff)
					{  
						strcpy(B[j].GetId(),B[j+1].GetId());
						strcpy(B[j].GetName(),B[j+1].GetName());
						strcpy(B[j].GetNation(),B[j+1].GetNation());
						strcpy(B[j].GetAddress(),B[j+1].GetAddress());
						strcpy(B[j].GetPost(),B[j+1].GetPost());
						strcpy(B[j].GetSalary(),B[j+1].GetSalary());
						strcpy(B[j].GetPaper(),B[j+1].GetPaper());
						++j;
					}
					B[j].Empty = true;
					--NumberofStaff;
				}
				return true;
			}
		}
		cout<<"Staff record not found!"<<endl;
		return true;
	}
	else if(menu[0] == '5')
	{	
		system ("CLS");
		SaveStaffRecord();
	    return true;
	}
	else if(menu[0] == '6')
		return false;
	else 
	{   
		system ("CLS");
		cout<<"Unknown Command. Please try again!\n";
	    return true;
	}
	return false;
}
//******************** end of Staff Menu operation *******************

//***************************** main program **************************
void main()
{
	if (!OpenStudentRecord()) 
	{
		cout<<"Fail to open student record!"; 
		return;
	}
	


	do{
	   system("CLS");
	   cout<<"************************************************"<<endl;
	   cout<<"***    UNIMAS DATA MANAGEMENT SYSTEM (DMS)   ***"<<endl;
	   cout<<"************************************************"<<endl;
	   cout<<"1. Student "<<endl;
       cout<<"2. Staff "<<endl;
	   cout<<"3. Exit "<<endl;
	   cout<<"Please enter your choice: ";
	   cin.getline(menu,10);
	   if (menu[0]=='1') while (StudentMenu());
	   else if (menu[0]=='2') while (StaffMenu());
	   else if (menu[0]=='3') break;
	   else
	   {
		cout<<"Unknown Menu, please try again!"<<endl;
	   }
	}
	while(menu[0]!='3');
}


Due to the source code too long, so i separate it in to pieces to post it. Please help me check it out. Why object S[1000] uses undefined class'Student' and unexpected end of file errors ?
Topic archived. No new replies allowed.