|
|
|
|
|
|
|
/* in */ int endX,
/* in */ int endY );
private:
|
|
|
|
|
|
|
|
|
8. Write the function definition for the Line class constructor. (pp. 922925) |
|
|
|
|
|
|
|
|
9. What is the difference between static and dynamic binding of an operation to an object? (pp. 925930) |
|
|
|
|
|
|
|
|
10. Although there are many specific techniques for performing OOD, this chapter uses a three-step process. What are these three steps? (pp. 930934) |
|
|
|
|
|
|
|
|
11. When selecting a data representation for an abstract object, what three choices does the C++ programmer have? (pp. 934935) |
|
|
|
|
|
|
|
|
Answers 1. functions, objects 2. Data abstraction, inheritance, dynamic binding |
|
|
|
|
|
|
|
|
3. class Pixel : public Point
{
public:
StatusType CurrentStatus() const;
pixel( /* in */ int initX,
/* in */ int initY,
/* in */ StatusType initStatus );
private:
StatusType status;
};
4. Pixel onePixel(3, 8, OFF);
5. cout < "x-coordinate: " <somePixel.X_Coord() < endl;
cout < "y-coordinate: " < somePixel.Y_Coord() < endl;
if (somePixel.CurrentStatus() == ON)
cout < "Status: on" < endl;
else
cout < "Status: off" < endl;
6. Pixel::Pixel( /* in */ int initX,
/* in */ int initY,
/* in */ StatusType initStatus )
: Point(initX, initY) // Constructor initializer
{
status = initStatus;
}
7. Point startPt;
Point endPt;
8. Line::Line( /* in */ int startX,
/* in */ int startY,
/* in */ int endX,
/* in */ int endY )
:startPt(startX, startY), endPt(endX, endY)
{
|
|
|
|
|
|