/*
This programe uses file stream to save student objects --- GIVES ERROR
-------------------------------------------------------------
error C2501: 'TotalStudents' : missing storage-class or type specifiers
Please help me resolve this error
*/
class Person
{
protected:
char name[20];
};
class Student:public Person
{
private:
char regnum[10];
char programme[8];
int semester;
float cgpa;
//open the file to save this student object
objFile.open("Students.dat",ios::out | ios::app | ios::binary);
objFile.write((char*)this,sizeof(*this));
}
class StudentOP
{
private:
static enum {MAX=50};
static Student objP[MAX];
public:
static int TotalStudents;
static void CreateStudentDB()
{
LoadStudentObjects(false);
do
{
Student s;
s.AddNewStudent();
objP[TotalStudents] = s;
TotalStudents++;
cout<<"Add new student(y/n): ";
}while(getch() == 'y');
//TotalStudents = i;
}
//get total no of students by dividing total file size by a student object size
static int GetTotalStudents()
{
ifstream objFile;
objFile.open("Students.dat",ios::binary);
objFile.seekg(0,ios::end);