StotleD
03-21-2007, 05:03 AM
I'm getting the strangest error when I try to compile my code:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 50. Copy constructor and assignment operator of ios_base
private:
ios_base(const ios_base&);
ios_base&
operator=(const ios_base&);
};
Does anyone know what that means? Here is my code. For the most part, all it is suppose to do is output a student's first and last name, along with their grade:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
const int arraySize = 20;
struct studentType
{
string studentFName;
string studentLName;
int testScore;
char grade;
};
void readData(ifstream& indata, studentType student[], int arraySize);
void assignData(ifstream& indata, studentType student[], int arraySize);
int highestScore(ifstream& indata, studentType student[], int arraySize);
void print(ofstream outfile, studentType student[],int arraySize);
//..............................................................................
int main()
{
ifstream readInfile;
ofstream readoutfile;
studentType Student[arraySize];
readInfile.open("c:\\Ch10_Ex1Data.txt");
readoutfile.open("c:\\Ch10_OutData.out");
readData(readInfile, Student, arraySize);
assignData(readInfile, Student, arraySize);
highestScore(readInfile, Student, arraySize);
print(readoutfile, Student, arraySize);
readInfile.close();
readInfile.clear();
readoutfile.close();
readoutfile.clear();
system("PAUSE");
return 0;
}
//..............................................................................
void readData(ifstream& indata, studentType student[], int arraySize)
{
int index;
for (index=0; index < arraySize; index++)
{
indata >> student[index].studentFName >> student[index].studentLName
>> student[index].testScore;
}
}
void assignData(ifstream& indata, studentType student[], int arraySize)
{
int index;
for (index = 0; index < arraySize; index++)
{
if (student[index].testScore >= 90)
student[index].grade = 'A';
else if (student[index].testScore >= 80)
student[index].grade = 'B';
else if (student[index].testScore >= 70)
student[index].grade = 'C';
else if (student[index].testScore >= 60)
student[index].grade = 'D';
else
cout << "failing grade" << endl;
}
}
int highestScore(ifstream& indata, studentType student[], int arraySize)
{
int highestScore = student[0].testscore;
int index;
for (index = 1; index < arraySize; index++)
if (student[highestScore].testScore < student[index].testScore)
highestScore = index;
return highestScore;
}
void print(ofstream& outfile, studentType student[], int arraySize)
{
int index;
int bestScore = highestScore(readInfile, Student, arraySize);
for (index = 0; index < arraySize; index++)
outfile << student[index].studentLName << "'" << " " << student[index].studentFName
<< student[index].testScore << "'" << " " << student[index].grade << endl;
for (index = 1; index < arraySize; index++)
if (student[index].testScore == bestScore)
outfile << "The highest score what achieved by " << student[index].studentLName << " "
<< student[index].studentFName << " with a score of " << student[index].testScore
<< endl;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 50. Copy constructor and assignment operator of ios_base
private:
ios_base(const ios_base&);
ios_base&
operator=(const ios_base&);
};
Does anyone know what that means? Here is my code. For the most part, all it is suppose to do is output a student's first and last name, along with their grade:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
const int arraySize = 20;
struct studentType
{
string studentFName;
string studentLName;
int testScore;
char grade;
};
void readData(ifstream& indata, studentType student[], int arraySize);
void assignData(ifstream& indata, studentType student[], int arraySize);
int highestScore(ifstream& indata, studentType student[], int arraySize);
void print(ofstream outfile, studentType student[],int arraySize);
//..............................................................................
int main()
{
ifstream readInfile;
ofstream readoutfile;
studentType Student[arraySize];
readInfile.open("c:\\Ch10_Ex1Data.txt");
readoutfile.open("c:\\Ch10_OutData.out");
readData(readInfile, Student, arraySize);
assignData(readInfile, Student, arraySize);
highestScore(readInfile, Student, arraySize);
print(readoutfile, Student, arraySize);
readInfile.close();
readInfile.clear();
readoutfile.close();
readoutfile.clear();
system("PAUSE");
return 0;
}
//..............................................................................
void readData(ifstream& indata, studentType student[], int arraySize)
{
int index;
for (index=0; index < arraySize; index++)
{
indata >> student[index].studentFName >> student[index].studentLName
>> student[index].testScore;
}
}
void assignData(ifstream& indata, studentType student[], int arraySize)
{
int index;
for (index = 0; index < arraySize; index++)
{
if (student[index].testScore >= 90)
student[index].grade = 'A';
else if (student[index].testScore >= 80)
student[index].grade = 'B';
else if (student[index].testScore >= 70)
student[index].grade = 'C';
else if (student[index].testScore >= 60)
student[index].grade = 'D';
else
cout << "failing grade" << endl;
}
}
int highestScore(ifstream& indata, studentType student[], int arraySize)
{
int highestScore = student[0].testscore;
int index;
for (index = 1; index < arraySize; index++)
if (student[highestScore].testScore < student[index].testScore)
highestScore = index;
return highestScore;
}
void print(ofstream& outfile, studentType student[], int arraySize)
{
int index;
int bestScore = highestScore(readInfile, Student, arraySize);
for (index = 0; index < arraySize; index++)
outfile << student[index].studentLName << "'" << " " << student[index].studentFName
<< student[index].testScore << "'" << " " << student[index].grade << endl;
for (index = 1; index < arraySize; index++)
if (student[index].testScore == bestScore)
outfile << "The highest score what achieved by " << student[index].studentLName << " "
<< student[index].studentFName << " with a score of " << student[index].testScore
<< endl;
}