-
Definition File Problems
The complaint is 'Unexpected end of file when looking for precompiled header directive'. This message is given in all 3 of my .cpp files. Here is one of them:
Student_info.cpp
Code:
#include "Student_info.h"
using namespace std;
bool compare(const Student_info& x, const Student_info y)
{
return x.name < y.name;
}
istream& read(istream& is, Student_info s)
{
is >> s.name >> s.midterm >> s.final;
read_hw(is, s.homework);
return is;
}
istream& read_hw(istream& in, vector<double>& hw)
{
if(in) {
//get rid of previous contents
hw.clear();
double x;
while(in >> x)
hw.push_back(x);
in.clear();
}
return in;
}
Do you know what the error means? Actually here is the header file as well.
Student_info.h
Code:
#ifndef GUARD_Student_info
#define GUARD_Student_info
#include<iostream>
#include<string>
#include<vector>
struct Student_info{
std::string name;
double midterm, final;
std::vector<double> homework;
};
bool compare(const Student_info&, const Student_info&);
std::istream& read(std::istream&, Student_info&);
std::istream& read_hw(std::istream&, std::vector<double>&);
#endif
-
Okay I got it all to work out. There were a couple of syntax errors in my program and also I had to use this line of code at the beginning of all my .cpp files:
Code:
#include "StdAfx.h"
I only had that in my main source (.cpp) file to start with.