{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tutorial10.pptx - CSCI 1120 Introduction to Computing Using...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI 1120 Introduction to Computing Using C++ Tutorial 10: Account Inheritance Hierarchy Le LI SHB 1013 [email protected] 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Outline Case Study: Scenario Problem Analysis Inheritance Hierarchy Superclass and Subclass Test and Client Program Summary 2
Background image of page 2
Case Study 3 A bank try to efficiently represent customers’ bank a ccount by using OOP. Customers’ account usually has two operations Deposit money (called credit) Withdraw money (called debit) We discuss two specific types of accounts Savings accounts Checking accounts Should we define a class for each account? Customer account, savings account, and checking accoun t
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Outline Case Study: Scenario Problem Analysis Inheritance Hierarchy Superclass and Subclass Test and Client Program Summary 4
Background image of page 4
Problem analysis (a) 5 We find that the member functions and variable s among the accounts are overlapped . When designing two or more classes that are di fferent but share some common features, we us e inheritance . The customer account can be viewed as the bas e class (or, superclass) , then the savings account and checking account can be viewed as the deri ved classes (or, subclass) .
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Problem analysis (b) 6 Base class: Account Data member: (type double ) to represent the account balance Constructor
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}