cannot re-declare my object

Hey there, i have a problem storing the records in a external file to my array using OOP. here is my code
header:
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
#include <fstream.h>

const int SIZE=100;

class Student
{
	protected:
		char StudentID[7];
		char *Name;
		char *SkillArea;
		char StudentType;
		int NoOfSubjects;
		char Result;

	public:

		char *get_id ();      void set_id(char[7]);
		char get_name();      void set_name(char*);
		char get_skill();     void set_skill(char*);
		char get_type();      void set_type(char);
		int get_nosub();      void set_nosub(int);
		char get_result();    void set_result(char);

		Student ();
		Student (char id[7], char *nam, char *skill, char type,int num,char re);

		void display();
		friend ifstream& operator>>(ifstream& in, Student& stud);
};


functions:
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
#include "PartbQ1header.h"
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
//==============================================================================
//
//Student class
//
//==============================================================================
Student::Student()
{
	strcpy(StudentID," ");
	strcpy(Name," ");
	strcpy(SkillArea," ");
	StudentType = 0;
	NoOfSubjects = 0;
	Result = 0;
}

Student::Student(char id[7], char *nam, char *skill, char type,int num, char re)
{
	strcpy(StudentID,id);
	strcpy(Name,nam);
	strcpy(SkillArea,skill);
	StudentType = type;
	NoOfSubjects = num;
	Result = re;
}

char *Student::get_id ()
{
	return StudentID;
}

void Student::set_id(char id[7])
{
	strcpy(StudentID,id) ;
}

	
char Student::get_type()
{
	return StudentType;
}
		
void Student::set_type(char type)
{
	StudentType = type;
}

int Student::get_nosub()
{
	return NoOfSubjects;
}
		
void Student::set_nosub(int num)
{
	NoOfSubjects = num;
}

char Student::get_result()
{
	return Result;
}

void Student::set_result(char re)
{
	Result = re;
}

void Student::display()
{
	cout<<setiosflags(ios::left)
		<<setw(6)<<StudentID
		<<setw(40)<<Name
		<<setw(10)<<StudentType
		<<setw(15)<<SkillArea
		<<setw(10)<<NoOfSubjects
		<<Result
		<<endl;
}

ifstream& operator>>(ifstream& in, Student& stud)
{
	in.get(stud.StudentID,7);
	in.getline(stud.Name,40,'*');
	in>>stud.StudentType;
	in.getline(stud.SkillArea,20,'*');
	in>>stud.NoOfSubjects;
	in>>stud.Result;
	in.ignore(80,'\n');

	return in;
}



void ENTER_RESULTS()
{
	char date[11], StudentID[7],id[7], *Name, StudentType, *SkillArea, Result,temp[80];
	int i, NoOfSubjects, count;
	bool again;

	ifstream infile;
	ofstream outfile;

	infile.open("STUDENT.DAT",ios::in);

	if(infile.fail())
	{
		cout<<"File does not exist.\n";
		exit(1);
	}

	infile.getline(date,11);
	infile.ignore(5,'\n');
	cout<<date;
	Student *staff[SIZE];


	count = 0;

	while(!infile.eof())
	{

		Student *tep = new Student;

		infile>>*tep;

		staff[count] = tep;

		staff[count]->display();
		count++;



	}
	infile.close();

}

int main()
{
	ENTER_RESULTS();
	cout<<endl;
	system("pause");
	return 0;
}

		

	


please help! thanks a lot
Last edited on
Sorry... what is your problem, exactly? Because for me, this compiles just fine.

-Albatross
i couldn't display and the program just bomb. is it because of my c++ software.
More specific, please?

What is the error?
i couldn't use my overloading operator to read the file.
Would you care to post the error message?
there is no error message. the program just bombed
What do you mean by "bombed"? Runtime error? Does the debugger show a break point?
what is "PartbQ1header.h"?
If for some reason your program cannot open the file, it will exit before you can see the error. This could be the problem.
Topic archived. No new replies allowed.