CS 14 - Lab 4


CS 14 Homepage

Class Inheritance and Operator Overloading

In this lab you will get some programming experience with class inheritance and operator overloading. You will have 3 seperate classes that together will define a cylinder and its location. The cylinder is made up of its height (Cylinder class), area of a 2D splice of the cylinder (Circle class), and xy point locations (Point class). You will have to make good judgements on what functions/variables should be public or private and what kind of inheritance to use. (Remember to use good encapsulation)

Pre-lab Preperation

Read chapter 8. Come to lecture!! Bring your lecture notes and book to lab.

ABSOLUTELY THE MOST IMPORTANT POINT....

It is extremely important that you get this lab working. The next lab will build upon this lab and I will not be giving you a solution for this lab. You will need to use the code that you write this week for the next lab. This means that if you get the code completely done in lab, you need to make sure both partners have a working copy of the code. If you do not get the code completed in lab, you must complete it outside of lab before your next lab session.

The Lab

Write a class called Point. It will contain two data members of type double to hold the x and y coordinates of the point. It should also contain the following function members: Now write a class called Circle. It will inherit the class Point and have one double data member for the radius. The following member functions should also be written. Lastly, write a class called Cylinder. This class will inherit the class Circle. It will have a data member of type double to hold the height. It will also contain the following member functions.
You will use main.cc to demo your program.

Point Breakdown - In Lab Demo

For this assignment, you will demo your program in lab. Please show the output from main.cc to the TA. Remember, you can get partial credit for showing that you have some of the correct results. The TA will also look at your code for correctness when checking out. Remember, to receive credit for this lab, you MUST turn the code in online as well as demo in lab, however, you will only receive points for what you demo to the TA during lab section. If you do not turn in your code online, you will lose points for your lab. All code must be turned in online for archival purposes. Remember to put both partners names on the code that you turn in.

Remeber to compile your code using the flags "-g -Wall -W -Werror -pedantic". You must have a makefile for this lab.