Hi.. I am having a slight problem with one of my projects and was wondering if anyone could help. I do not understand why this is not working like it should.
Here is my class(this is a base class for a referencing class).
date.h
Code:
#include <iostream>
using namespace std;
class date {
private:
int month;
int day;
int year;
public:
date();
date(int,int,int);
friend istream &operator >>(istream &in, date &d);
};
date.cpp
Code:
#include "date.h"
#include <iostream>
using namespace std;
date::date() : month(0), day(0), year(0) {}
date::date(int month, int day, int year) {
}
istream &operator >>(istream &in, date &d) {
in >> d.day >> d.month >> d.year;
return in;
}
Referencing class
insurance.h
Code:
#include <string>
#include <iostream>
#include "date.h"
using namespace std;
class insurance: public date {
protected:
string firstName;
string lastName;
char gender;
date birthDate;
protected:
static int total;
public:
insurance();
insurance(string, string, char, date);
void readInfo(istream &in);
};
insurance.cxx
Code:
#include "insurance.h"
#include <iostream>
#include <string>
using namespace std;
insurance::insurance() : firstName(""), lastName("") {}
insurance::insurance( string firstName, string lastName, char gender,
date birthDate) {}
void insurance::readInfo(istream &in) {
in >> firstName >> lastName >> gender >> birthDate;
}
So, in main when I call the insurance.readinfo(inFile); function, I'm assuming that the stream for the date members should be readinto the date's class datamembers?... However, im unsure if they are being read, or if im just having a problem accessing them..
Would I need to create a member function to "GET" the data members stored in the "insurance.birthDate" Date object? if so how would this be implemented? each time I try to create something like this I get errors saying the datamembers are private...
I want to eventually just use cout like
Code:
cout << getDay(birthDate) << "\n";
to get it to work?
any suggestions?