Hi! I'm currently taking OOD for C++ and had to write a program using classes, but for some reason, I keep getting the "fatal error C1083: Cannot open include file: 'student': No such file or directory" when compiling. I followed the book's instructions and still have no solution. If anyone could help, it would be greatly appreciated. Thanks!
allPeople.h
Code:
#ifndef H_AllPeople
#define H_AllPeople
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class allPeople
{
public:
//Function to set person's first name, last name, and
//id number.
void setNameInfo (string first, string last, int idNumber);
//Function to print name and idNumber.
void print () const;
//Constructor
allPeople (string first="", string last="", int idNumber=0);
protected:
string fName; //variable stores first name
string lName; //variable stores last name
int personID; //variable stores ID number
};
void allPeople::print () const
{
cout << "The person's name is " << fName << " " << lName << endl;
cout << "and their ID number is " << personID << "." << endl;
}
//Function to output the first name, last name and ID number.
//Postcondition: Outputs
//The person's name is fName lName
//and their ID number is personID.
void allPeople::setNameInfo (string first, string last, int idNumber)
{
fName = first;
lName = last;
personID = idNumber;
}
//Function to set the first name, last name, and ID number
//according to the parameters.
//Postcondition: fName=first; lName=last; personID=idNumber
allPeople::allPeople (string first, string last, int idNumber)
{
fName=first;
lName=last;
personID=idNumber;
}
#endif
student.h
Code:
#ifndef H_Student
#define H_Student
#include <iostream>
#include <string>
#include <iomanip>
#include "allPeople"
using namespace std;
class student: public allPeople
{
public:
//Function to set the student information.
void setStudentInfo (string first, string last,
int idNumber, string stuStatus);
//Function to print the name, ID number and status.
void print () const;
//Constructor
student(string first="", string last="", int idNumber=0,
string="");
private:
static string peopleClass;
string studentStatus;
};
string student::peopleClass = "Student";
void student::setStudentInfo (string first, string last, int idNumber,
r string stuStatus)
{
//use allPeople class to set the first, last, and idNumber
allPeople::setNameInfo(first, last, idNumber);
studentStatus = stuStatus;
}
void student::print () const
{
allPeople::print (); //uses allPeople class to print name and ID
cout << "The classification of this person is " << peopleClass << "."
<<endl;
cout << "The status of this person is " << studentStatus << "." <<
endl;
}
student::student (string first, string last, int idNumber, string
stuStatus)
: allPeople (first, last, idNumber)
{
studentStatus = stuStatus;
}
#endif
faculty.h
Code:
#ifndef H_Faculty
#define H_Faculty
#include <iostream>
#include <string>
#include <iomanip>
#include "allPeople"
using namespace std;
class faculty: public allPeople
{
public:
//Function to set the faculty information.
void setFacultyInfo (string first, string last,
int idNumber, double salary);
//Function to print the name, ID number and salary.
void print () const;
//Constructor
faculty(string first="", string last="", int idNumber=0,
double salary=0);
private:
static string peopleClass;
double facultySalary
};
string faculty::peopleClass = "Faculty";
void faculty::setFacultyInfo (string first, string last, int idNumber,
double salary)
{
//use allPeople class to set the first, last, and idNumber
allPeople::setNameInfo(first, last, idNumber);
personSalary = salary;
}
void faculty::print () const
{
allPeople::print (); //uses allPeople class to print name and ID
cout << "The classification of this person is " << peopleClass << "."
<<endl;
cout << "The salary of this person is " << personSalary << "." <<
endl;
}
faculty::faculty (string first, string last, int idNumber, double
salary)
: allPeople (first, last, idNumber)
{
personSalary = salary;
}
#endif
staff.h
Code:
#ifndef H_Staff
#define H_Staff
#include <iostream>
#include <string>
#include <iomanip>
#include "allPeople"
using namespace std;
class staff: public allPeople
{
public:
//Function to set the staff information.
void setStaffInfo (string first, string last,
int idNumber, string empStatus);
//Function to print the name, ID number and status.
void print () const;
//Constructor
staff(string first="", string last="", int idNumber=0,
string="");
private:
static string peopleClass;
string employmentStatus;
};
string staff::peopleClass = "Staff";
void staff::setStaffInfo (string first, string last, int idNumber,
string empStatus)
{
//use allPeople class to set the first, last, and idNumber
allPeople::setNameInfo(first, last, idNumber);
employmentStatus = empStatus;
}
void staff::print () const
{
allPeople::print (); //uses allPeople class to print name and ID
cout << "The classification of this person is " << peopleClass << "."
<<endl;
cout << "The status of this person is " << employeeStatus << "." <<
endl;
}
staff::staff (string first, string last, int idNumber, string
empStatus)
: allPeople (first, last, idNumber)
{
employeeStatus = empStatus;
}
#endif
test.cpp
Code:
#include <iostream>
#include <string>
#include <iomanip>
#include "student"
#include "faculty"
#include "staff"
using namespace std;
int main()
{
//Program to test University Program.
cout << "This is a test for the University Program." << endl;
//Testing for correct output based on test data.
cout << "Now testing for correct output based on test data." << endl;
cout << "Test for student data" << endl;
student studentTest ("Joan", "Doe", 1020202, "Full Time");
studentTest.print();
cout << endl;
cout << "Test for staff data" << endl;
staff staffTest ("John", "Smith", 1000000, "Part Time");
staffTest.print();
cout << endl;
cout << "Test for faculty data" << endl;
faculty facultyTest ("Bob", "Jones", 3333333, 100000.00);
faculty.print();
cout << endl << endl << endl;
system ("pause");
return 0;
} //end main program