Jan 26, 2015 at 2:06am Jan 26, 2015 at 2:06am UTC
Help me please! IM entering this code ,but it is not working for some reason. Its from Accelereated c++ ,Chapter 4. The problem is every time i put this code in a error pops up saying "grade.h no such file" what is wrong with my code?
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
#include <iostream>
#include <string>
#include <ios>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <iomanip>
#include "grade.h"
#include "Student_info.h"
using std:: cin;
using std:: cout;
using std:: domain_error
using std:: endl;
using std:: max;
using std:: setprecision;
using std:: sort;
using std:: streamsize;
using std:: string
using std:: vector;
using namespace std;
int main ()
{
vector <Student_info> students;
Student_info record;
string::size_type maxlen = 0;
while (read(cin,record)) {
//find legnth of longest name
maxlen = max(maxlen, recor.name.size()) ;
students.push_back(record);
}
//alphabetize the student records
sort (students.begin(), students.end() compare);
//write the name and grades
for (vector<Student_info>:;size_type i=0;
i != students.size(); i++) {
cout << students[i].name
<< string(maxlen +1 - students[i].name.size(), ' ' );
//compute and write the grade
try {
double final_grade = grade (students[i]);
streamsize prec = cout.precision();
cout << setprecision(3) << final_grade
<< setprecisoin(prec);
}
catch (domain_error e) {
cout << e.what();
}
cout << endl;
}
}
--Justin
Last edited on Jan 26, 2015 at 2:11am Jan 26, 2015 at 2:11am UTC
Jan 26, 2015 at 2:21am Jan 26, 2015 at 2:21am UTC
Make sure the file grade.h file is in the same directory as the main.cpp file, if it isn't either move to that directory or change the include statement to include the path to the grade.h file.
Jan 26, 2015 at 10:24am Jan 26, 2015 at 10:24am UTC
Unrelated to your problem, but what is the point of lines 10-18?
The individual using
statements are defeated by line 22.
Last edited on Jan 26, 2015 at 10:25am Jan 26, 2015 at 10:25am UTC
Jan 27, 2015 at 1:56am Jan 27, 2015 at 1:56am UTC
@AbstractionAnon Its what the book says I know its completely useless ,but hey why not!
--Justin
Jan 27, 2015 at 5:07pm Jan 27, 2015 at 5:07pm UTC
If the book has you doing both selective using namespace
and using namespace std;
, it's a poor example. A book should not be teaching you to write useless lines of code.