COSC 1337 - Programming Fundamentals II


Chapter 11 More on Classes

Review Exercises

I recommend that you review the chapter by doing these exercises. I will NOT grade these exercises.

Consider reviewing the Checkpoint questions from this chapter.
Answers to Checkpoint questions are in Appendix P (on the CD that came with your textbook).

Review Questions and Exercises: 7, 9.
Answers to Review Questions and Exercises are in Appendix Q (on the CD that came with your textbook).

Other Questions

1. Given the partial class definition:

class Point
{
private:
   int x;
   int y;
public:
   ...
};

You want to add a constructor function that sets each of the data members to zero. What is wrong with this constructor implementation?

Point::Point( int x, int y )
{
   x = 0;
   y = 0;
}

2. Given the partial Point class from the previous problem, you want to add a set function that changes the data members to values specified by the client programmer. What is wrong with this implementation?

void Point::set( int newX, int newY ) const
{
   x = newX;
   y = newY;
}

Answers to Other Questions are here.


Creative Commons License
© Austin Community College 2016. The content on this page is licensed under a
Creative Commons Attribution 4.0 International License.
Last updated: July 15, 2013