CS 1440 Lab 8
· More practice with C++ classes
· Passing class objects as parameters and return types
Copy and paste the Date class definition and the Date:: function definitions from the previous activity into a file named Act3.C.
Add to Act3.C the definition of a Person class. A "Person" has a name (which is a string) and a birthday (which is a Date). We can "set" the values of Person's data members and Display Personal information.
Want to try to define the class yourself? Go ahead, you can peek below if you get stuck.
void set(string n, Date bd);
Here are the class function definitions (notice how a Date object is passed as a parameter):
void Person::set(string n, Date bd)
name = n;
birthday = bd;
cout << name << " has a birthday on ";
cout << endl;
Here is the main function AND another function that just gets Dates. Notice that this is not part of the Date class, and that it returns a Date object.
cout << "Enter mom's name: ";
bday = getDate();
/* Date is return type; this is NOT class function */
int m, d, y;
cout << "Enter month: ";
cin >> m;
cout << "Enter day: ";
cin >> d;
cout << "Enter year: ";
cin >> y;
Put it all together: the Date class, the Person class, the main, the getDate, and whatever header files are needed. Make sure it works by compiling and running it.