CISC181, Practice With Classes In both cases, write the complete class declaration as a .h file, and defintions for all member functions as a .cc file. Just for today: all member function definitions in the .cc file, and the function prototypes for member functions in the .h file (along with the declaration of data members.) (Yes, it is possible to do function defs inside the class .h file but for today, we won't). Be sure to use pre-processor directives to make your .h file idempotent. Be sure to use "const" on all member functions where it is appropriate. (1) Write a class to represent a point in the Cartesian plane. Represent x and y as double. Include * a constructor that initializes the point to the origin * set and get functions for x and y Also include a function distFromOrigin() the returns the distance from the origin, and a function that returns the angle of that point in radians (both functions should return double.) (2) Write a class to represent a time of day (hours and minutes). Include a constructor that takes an integer # of hours, and integer # of minutes in military time (e.g. 13:25 represents the start time for the 010-012 section lecture, and 14:30 represents the start time of the 013-015 section lecture.) Include set and get functions for hour and minute. The setHour() function and setMinute() functions should return bool--- return true if the parameter values were valid and the attribute was set, and return false if the parameter values were NOT valid, and the attribute was NOT set. For the constructor, if invalid values were passed in, just set the value of the time to 00:00 (i.e. midnight). (3) Suppose I had the following files, related to question 2 above. timeOfDay.cc timeOfDay.h main.cc How would I compile these into a useful program? Suppose that main.cc contains the following: // main.cc An example of USING the time class #include using namespace std; #include "timeOfDay.h" int main(void) { // each of these invokes the constructor TimeOfDay_C dinnerTime(18,30); // dinner is at 6:30pm TimeOfDay_C breakfast(08,15); // breakfast is at 8:15am TimeOfDay_C officeHrsStart(15, 45); // breakfast is at 8:15am cout << "If I call getHours on officeHrsStart, I get: " << officeHrsStart.getHours() << endl; return 0; } Answer: I need to compile the .cc files separately, and then link them together into an executable. To compile the .cc files separately do: CC -c timeOfDay.cc CC -c main.cc To link the two together, do: CC timeOfDay.o main.o -o main The thing that follows the -o should be the name of executable file that you want to create. It typically is called by the same name as the .cc file that contains the "int main(void)" line or the "int main(int argc, char *argv[]) line. (4) Suppose I wanted to create a Makefile to go along with timeOfDay.cc and main.cc. What would it look like? Answer: See the file "Makefile" in the current directory for an answer.