Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Notes on Object Analogy - Object Oriented Programming for Engineers | CSE A215, Study notes of Engineering

Material Type: Notes; Professor: Miller; Class: Object Oriented Programming for Engineers; Subject: Computer Systems Engineering ; University: University of Alaska - Anchorage; Term: Spring 2009;

Typology: Study notes

2009/2010

Uploaded on 03/28/2010

koofers-user-1qb
koofers-user-1qb 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE294B
Object-Oriented C++ Programming for Engineers
Lecture #8
Jeffrey Miller, Ph.D.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Notes on Object Analogy - Object Oriented Programming for Engineers | CSE A215 and more Study notes Engineering in PDF only on Docsity!

CSE294B

Object-Oriented C++ Programming for Engineers

Lecture #8 Jeffrey Miller, Ph.D.

Object Analogy

-^ To drive a car, you need the accelerator pedal, thebrake pedal, the steering wheel, and the ignition(at minimum) •^ But what actually happens when you turn the keyin the ignition?^ –^ Most drivers do not know, but they do not need toknow to be able to drive the car •^ This is the idea behind objects^ –^ The code that uses the object knows

what^ the function will do, but does not need to know

how^ it does it

Object Descriptions • Objects (and in turn, classes) can bedescribed by two key features – Data – Functions • The functions of an object operate on thedata that is part of the object or data that ispassed into the function (possibly inconjunction with the data of the object)

Bank Account Object • What is the data that is associated with a bank account? – Name – Account Number – Balance – PIN • What are the functions that can be performed on a bankaccount? – Deposit – Withdrawal – Transfer – Check Balance – Change PIN

Access Specifiers

-^ There are two access specifiers in C++^ –^ public^ –^ private •^ If a variable or function is declared public, any other pieceof code can access the variable or function •^ If a variable or function is declared private, only the classin which that variable or function is declared can access it •^ Rule of Thumb – Hide the data and expose the necessaryfunctions

Encapsulation

-^ A class is considered

encapsulated

if all of

the data is declared private • A class is considered

fully encapsulated

if

all of the data is declared private AND youprovide an accessor (getter) andmanipulator (setter) function for each pieceof data^ –^ Manipulators are also called mutators

Homework

-^ Homework #3 is posted!