void Sort(int count, Student* s[])
{
bool swapped = true;
Student* temp;
do {
swapped = false;
for(int i = 0; i < count-1; i++)
{
if(strcmp(s[i]->getLast(), s[i+1]->getLast()) < 0 )
{
temp = s[i];
s[i] = s[i+1];
s[i+1] = temp;
swapped = true;
}
cout << "Address is: "<<s[i]<<endl;
}
} while(swapped == true);
}
Part of main.cpp
int main ()
{
char * inputFile;
char outputFile[MAXFILENAMESIZE];
int sCount = 0;
//Get a VALID input file.
inputFile = givemeinput();
cout << "Please enter the name of the output file.\n";
cout << "Filename: ";
cin >> outputFile;
//Create an ouput file for use.
ofstream fout (outputFile, ios::app);
//Get the number of students to read in.
sCount = studentCount(inputFile);
//Declaration of array of pointers.
Student** sArray;
//Implementing the actual work. Loads pointer
//sArray with all information.
sArray = fillArray(inputFile, sCount, sArray);
//Print all the information to our specified file.
PrintToFile(sCount, sArray, fout);
cout << "Processing Complete\n";
for(int i = 0; i < sCount; i++)
delete sArray[i];
// Sort(sCount, sArray);
return 0;
}
HEADER file
class Student
{
public:
Student();
Student(char* l, char* f, char* c);
//Both are pure virtual functions. Retrieves specific
//data from derived classes.
virtual double ComputeAverage()=0;
virtual int getFinal()=0;
char* getLast();
char* getCourse();
char* getFirst();
protected:
char last[21];
char first[21];
char course[10];
};
class English : public Student
{
public:
English();
English(char* l, char* f, char* c, int attEND, int proJ,
int miD, int finalEXAM);
private:
double ComputeAverage();
int getFinal();
int attend;
int proj;
int midterm;
int finalExam;
};
class History : public Student
{
public:
History();
History(char* l, char* f, char* c, int term, int mid,
int final);
private:
//ComputeAverage() and getFinal() are called from the
//pure virtual function in the 'Student' class.
double ComputeAverage();
int getFinal();
int termPaper;
int midterm;
int finalExam;
};
class Math : public Student
{
public:
Math();
Math(char* l, char* f, char* c, int qOne, int qTwo,
int qThree, int qFour, int qFive, int tOne, int tTwo,
int final);
private:
//ComputeAverage() and getFinal() are called from the
//pure virtual function in the 'Student' class.
double ComputeAverage();
int getFinal();
int quiz_Average;
int quizOne;
int quizTwo;
int quizThree;
int quizFour;
int quizFive;
int testOne;
int testTwo;
int finalExam;
};
This post has been edited by dekker13: 01 April 2012 - 05:16 PM

New Topic/Question
Reply



MultiQuote






|