HI,
Im trying to get this to work, however i cannot and it is driving me crazy, what I have is a text file from which i am trying to read in the data into members of a base class, and two derived classes:
Base class:
Code:
class insurance: public date {
private:
string firstName;
string lastName;
char gender;
date birthDate;
protected:
int total;
};
Derived class 1:
Code:
class car : public insurance {
private:
std::string manufacturer;
std::string model;
int year;
std::string color;
int size;
public:
car();
car(std::string, std::string, int, std::string, int);
Derived class II:
Code:
class health : public insurance {
private:
int type;
int coverage;
int size;
public:
health();
health (int,int,int);
main.cpp
Code:
int MAX_SIZE = 100;
car c[MAX_SIZE];
health h[MAX_SIZE];
while(inFile) {
test types
inFile >> type;
if(type == 1) {
inFile >> c[i];
i++;
}
else if(type == 2) {
inFile >> h[i];
i++;
}
What I am trying to do is read in lines of a file....
formatted like this:
Code:
2 James Williams M 3 12 1980 1 1
I have tried overloading >> eg.. for the car class using the following function
Code:
istream operator >>(istream &in, car &c) {
in >> firstName >> lastName >> gender >> birthDate
>> manufacturer >> model >> year >> color;
// return in;
}
however I cannot seem to get it to work, if anyone has any ides, or sees anything im doing wrong please let me know, thanks in advance for any assistance.