Here are 2 steps in a hw problem for a class.
6. equalDate to compar e the dates of two Appointm ent objects, r eturn true if they are the same and false otherwise.
7. A constructor with default para meters. The default val ues are empty string for the name, 1900 for the year, 1 for the month, and 1 for the day.
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13
class Appointment
{
private:
string name;
Date date;
public:
void print() const;
void setName();
int getName();
void setDate();
int getDate();
bool equalDate(const Date obj) const;
Appointment(int y=1900, int m=1, int d=1);
class A
{
public:
A();
int someint;
double somedouble;
//etc....
}
A::A()
{
someint = 5;
somedouble = 5.2340;
}
The constructor initializes the values of the members someint and somedouble. By the way, you can also pass values to a constructor like any other function. Using your Appointment class as an example, the user could also set the date in the constructor for Appointment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Appointment
{
Appointment(int y_, int m_, int d_);
Date date;
//other stuff
}
Appointment(int y_, int m_, int d_)
{
date.y = y_;
date.m = m_;
date.d = d_;
//other initialization instructions
}