I'm having trouble using inheritance. I have a base class called "Individual", and i have a derived class called "Student". I created the classes and the functions for each, but i am getting the following errors: 'Individual' : 'class' type redefinition, and 'Individual' : base class undefined.
I think it has something to do with the constructors or with the class itself.
Header file of base class "Individual":
Code:
class Individual
{ <---- 'Individual' : 'class' type redefinition
public:
Individual(string, string, string);
private:
string Last_Name;
string First_Name;
string Phone_Number;
};
Function file of base class "Individual":
Code:
#include "assign4header.h"
Individual::Individual(string LastName, string FirstName, string PhoneNumber)
{
setLast_Name(LastName);
setFirst_Name(FirstName);
setPhone_Number(PhoneNumber);
}
Header file of derived class "Student":
Code:
#include "assign4header.h"
class Student : public Individual
{ <--------- 'Individual' : base class undefined
public:
Student(string, string, string, float, float);
private:
float GPA;
float Hours;
};
Funtion File of derived class "Student":
Code:
#include "assign4header2.h"
Student::Student(string LastName, string FirstName, string PhoneNumber, float GradeAvg, float HoursEnrolled )
:Individual(LastName, FirstName, PhoneNumber)
{
setGPA(GradeAvg);
setHours(HoursEnrolled);
}
The base class has members for the last name, first name, and phone number of a person. The derived class has members for the gpa and hours of enrollment of a person. So i should be able to create an object like this in main:
Code:
Student("Williams", "John", "555-1234", 4.0, 15.0);
I have appropriate set and get functions for both classes , but i left them out because i think the problem is with the constructors or class itself. If it is needed, i can put them in.