| ||Specialization, Extension, and Inheritance - slide 11 : 40|
An example of simple extension
We extend the 2D Point class to a 3D Point class
The class Point2D.
The class Point3D which extends class Point3d.
A client of the classes Point2D and Point3d.
The output from the Client program.
Point3D: A client or a subclass of Point2D?
- Some observations:
- A 3D point is not a 2D point
- Thus, Point3D is not a specialization of Point2D
- The set of 2D point objects is disjoint from the set of 3D points
The class Point2D was a convenient starting point of the class Point3D
We have reused some data and operations from class Point2D in class Point3D