![]() |
CMPT 212
Spring 1998
|
![]() |
Read chapter 13 (except sections with Template in the name) from C++ Primer Plus (2nd ed.), by Stephen Prata. |
class animal { ... }; class mammal : public animal { ... }; class egg_layer : public animal { ... }; class platypus : public animal, public egg_layer { ... }:
class Point { public: Point() { x_coord = 0.0; y_coord = 0.0; } Point(float x, float y) { x_coord = x; y_coord = y; } ... private: float x_coord; float y_coord; }; class Circle : public Point { public: Circle(); Circle(float x, float y, float r); ... private: float radius; }; Circle::Circle() { radius = 0.0; } Circle::Circle(float x, float y, float r) : Point(x, y), radius(r) { }We could also use initialization lists for the two Point constructors and the default Circle constructor.
![]() Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 11 Mar 1998. |