Hello all Im back with another crazy assignment from my professor and I'm running into the following debugging errors in Vi (we have to use it) so here are the errors:
Assign4.cpp: In member function âvoid cCourselist::Load(Infile_t&)â:
Assign4.cpp:105: error: expected unqualified-id before â[â token
Assign4.cpp:109: error: expected unqualified-id before â[â token
Assign4.cpp: In member function âvoid cCourselist::Print(Outfile_t&)â:
Assign4.cpp:120: error: expected unqualified-id before â[â token
Assign4.cpp: In member function âvoid cCourselist::Display()â:
Assign4.cpp:126: error: invalid operands of types âconst char [2]â and âconst char [12]â to binary âoperator<<â
Assign4.cpp:130: error: expected unqualified-id before â[â token
Here is the code:
#include<iomanip>
#include<iostream>
#include<fstream>
using namespace std;
const int NAMESIZE=11;
const int FILENAMESIZE=51;
const int ARRAYSIZE=20;
const int MAXCLASSSIZE=51;
int N=0;
typedef char Name_t[NAMESIZE];
typedef int Grade_t;
typedef char Filename_t[FILENAMESIZE];
typedef fstream Infile_t;
typedef fstream Outfile_t;
class cStudent
{
private:
Name_t fname;
Name_t lname;
Grade_t t1;
Grade_t t2;
Grade_t t3;
Grade_t t4;
Grade_t ag;
Grade_t eg;
public:
cStudent(){}
void Display();
cStudent(Name_t NewName, Grade_t NewGrade);
cStudent &operator=(const cStudent student)
{
student.get_fname(fname);
student.get_lname(lname);
student.get_t1(t1);
student.get_t2(t2);
student.get_t3(t3);
student.get_t4(t4);
student.get_ag(ag);
student.get_eg(eg);
}//end cStudent &operator
void Read(Infile_t &Infile);
void Print(Outfile_t &Outfile);
//set
void set_fname(Name_t first)
{ strcpy(fname,first);}
void set_lname(Name_t last)
{ strcpy(lname,last);}
void set_t1(Grade_t a)
{ t1=a;}
void set_t2(Grade_t b)
{ t2=b;}
void set_t3(Grade_t c)
{ t3=c;}
void set_t4(Grade_t d)
{ t4=d;}
void set_ag(Grade_t e)
{ ag=e;}
void set_eg(Grade_t f)
{ eg=f;}
//get
void get_fname(Name_t &fname) const
{ strcpy(fname,this->fname);}
void get_lname(Name_t &lname) const
{ strcpy(lname,this->lname);}
int get_t1(Grade_t &t1) const
{ t1=this->t1; return t1;}
int get_t2(Grade_t &t2) const
{ t2=this->t2; return t2;}
int get_t3(Grade_t &t3) const
{ t3=this->t3; return t3;}
int get_t4(Grade_t &t4) const
{ t4=this->t4; return t4;}
int get_ag(Grade_t &ag) const
{ ag=this->ag; return ag;}
int get_eg(Grade_t &eg) const
{ eg=this->eg; return eg;}
};
class cCourselist
{
private:
cStudent Student[MAXCLASSSIZE];
int Numofstudent;
void PrintHeader(Outfile_t &Outfile);
public:
cCourselist();
void Load(Infile_t &Infile);
void Print(Outfile_t &Outfile);
void Display();
};//end of cCourselist
typedef cStudent StudentArray[30];
cCourselist CSCI208;
void cCourselist::Load(Infile_t &Infile)
{
Filename_t Filename;
cout<<"Enter the name of the datafile:"<<endl;
cin>>Filename;
Infile.open(Filename,ios::in);
StudentArray[Numofstudent].Read(Infile);
while(!Infile.eof())
{
Numofstudent=Numofstudent+1;
StudentArray[Numofstudent].Read(Infile);
}//end while
Infile.close();
};//end of load
void cCourselist::Print(Outfile_t &Outfile)
{
Outfile<<setw(10)<<"Name"<<" "<<"Test Grades"<<" "<<"Assignment Grade"
<<" "<<"Exam Grade"<<endl;
for(int I=0; I<Numofstudent; I++)
{
StudentArray[I].Print(Outfile);
}//end for
};//end print
void cCourselist::Display()
{
cout<<"Name"<" "<<"Test Grades"<<" "<<"Assignment Grade"
<<" "<<"Exam Grade"<<endl;
for(int I=0; I<Numofstudent; I++)
{
StudentArray[I].Display();
}//end for
};//end display
int main()
{
cCourselist CSCI208;
Infile_t Infile;
Outfile_t Outfile;
CSCI208.Load(Infile);
CSCI208.Print(Outfile);
CSCI208.Display();
return 0;
}//end main
I have no idea where im going wrong, and I know this code is well crap but my professor insists on having us do stuff like this. Thanks to this site I have invested in some C++ books but I'm still very much a newbie and any help would be much welcomed
-atticusr5