CSE 2341 Object Oriented Programming with C Note Set 11 1 Quick Look More on Relationships Introduction to Inheritance 2 Review 3 types of relationships is a has a uses a 3 has a Aggregation Composition one object contains another object car has a motor human has a brain MorseEncoder has a MorseMap 4 aggregation class car public stuff private Motor myMotor class human public stuff private Brain myBrain 5 is a is a relationship that represents inheritance generalization class derivation For example Helicopter is a vehicle Train is a vehicle Truck is a vehicle Plane is a vehicle Motorcycle is a vehicle 6 Inheritance Diagram Vehicle CAR HELICOPTER TRAIN 7 Uses A Relationship An operation of class A receives or returns an object of class B In the process of an operation of class A an object of class B must be inspected or created Objects of class A contain a reference to objects of class B 8 Identify Relationships Sun Planet Elevator Rider Date Person Person Employee Circle Point Manager Employee Triangle Rectangle Computer Keyboard Computer Person Computer Laptop 9 Two Types of Inheritance Single BASE1 DerivedA Multiple BASE2 BASE3 DerivedC DerivedD DerivedB 10 Draw an Inheritance Diagram Person Student Name Address Professor 11 Fini 12
View Full Document
Unlocking...