2012-12-18 13:34:37 UTC
#include
#include
using namespace std;
class date;
class Time;
class date
{
friend ostream& operator <<(ostream&, date &);
//PreCondition: Function is passed the output stream and a DATE object
//Postcondition: Date is displayed in U.S. format (mm/dd/yyyy)
public:
date(); //default constructor, sets everything to 0
date(int, int, int); //constructor to initialize private member values
protected:
int month; //holds the month
int day; //holds the day
int year; //holds the year
};
class Time : public date
{
friend ostream& operator <<(ostream &, Time &);
//PreCondition: Fct is passed the output stream and an object of TIME
//PostCondition: Time is displayed in U.S. format with AM or PM (14:30:0 is displayed as 02:30:00 pm)
public:
Time(); //default constructor
Time(int, int, int, date &);
Time(int, int, int, int, int, int);
private:
int hour; //holds hours, 0-23
int minute; //holds minutes, 0-59
int second; //holds seconds 0-59
};
Time::Time()
{
hour = 0;
minute = 0;
second = 0;
}
Time::Time (int h, int m, int s, date &dobj)
{
hour = h;
minute = m;
second = s;
Time.month = dobj.month;
Time.day = dobj.day;
Time.year = dobj.year;
}
Time::Time (int h, int m, int s, int mm, int dd, int yyyy)
{
hour = h;
minute = m;
second = s;
Time.month = mm;
Time.day = dd;
Time.year = yyyy;
}
date::date()
{}
date::date (int mm , int dd, int yyyy)
{
month = mm;
day = dd;
year = yyyy;
}
FOR MY TIME CONSTRUCTORS, it says cannot access dobj.month, dobj.day , dobj.year even though it is passed a data object..
Also, for my other time constructor with all INTs, it says that I am "missing a ; before the ." HELP!