CSE 2341 Object Oriented Programming with C Note Set - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

CSE 2341 Object Oriented Programming with C Note Set

Description:

class car. public://stuff. private: Motor myMotor; class human. public://stuff. private: ... CAR. HELICOPTER. Vehicle. TRAIN. 8. Uses A Relationship ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 13
Provided by: markfo7
Learn more at: http://lyle.smu.edu
Category:

less

Transcript and Presenter's Notes

Title: CSE 2341 Object Oriented Programming with C Note Set


1
CSE 2341Object Oriented Programming with
CNote Set 11
2
Quick Look
  • More on Relationships
  • Introduction to Inheritance

3
Review
  • 3 types of relationships
  • is a
  • has a
  • uses a

4
has - a
  • Aggregation/Composition
  • one object contains another object

car has a motor human has a brain MorseEncoder
has a MorseMap
5
aggregation
class car public//stuff private Motor
myMotor
class human public//stuff private
Brain myBrain
6
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

7
Inheritance Diagram
Vehicle
CAR
HELICOPTER
TRAIN
8
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

9
Identify Relationships
  • Sun, Planet __________
  • Elevator, Rider __________
  • Date, Person __________
  • Person, Employee __________
  • Circle, Point __________
  • Manager, Employee __________
  • Triangle, Rectangle __________
  • Computer, Keyboard __________
  • Computer, Person __________
  • Computer, Laptop __________

10
Two Types of Inheritance
Multiple
Single
BASE2
BASE3
BASE1
DerivedA
DerivedC
DerivedD
DerivedB
11
Draw an Inheritance Diagram
  • Person
  • Student
  • Name
  • Address
  • Professor

12
Fini
?
Write a Comment
User Comments (0)
About PowerShow.com