Class - CSS342: Objects and Classes Professor: Munehiro...

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

View Full Document Right Arrow Icon
CSS342: Objects and Classes 1 CSS342: Objects and Classes Professor: Munehiro Fukuda
Background image of page 1

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

View Full DocumentRight Arrow Icon
CSS342: Objects and Classes 2 Today’s Topics Class Encapsulation and information hiding From a abstract data specification to a class design Examples List: a list of students Interface and implementation Constructors and destructors Rational: rational numbers Operator overloading
Background image of page 2
CSS342: Objects and Classes 3 Encapsulation and Information Hiding Wall: Not only encapsulate the entire implementation but also make it invisible/inaccessible. Slit : Interface of the implementation such as arguments and a return value. Implementation of method S Program that uses method S Function call with arguments Return a value Class
Background image of page 3

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

View Full DocumentRight Arrow Icon
CSS342: Objects and Classes 4 Class Classes: a new data type formed of a collection of data and a set of operations on the data Data Structures: a construct within a programming language that stores a collection of data add remove query Behave as a new data type Program that uses a class Examples: - student lists - rational numbers - complex numbers - currency (cents/dollars) - length measurement (inches/feet) - weight measurement (oz/lbs) Class
Background image of page 4
CSS342: Objects and Classes 5 List Class Specification Add a new student entry Delete a student entry Display a student entry Check # students Berger Cioch Olson Erdly Meske Liu McDaniel Fukuda Jackels Smolar Arnold Frank Clark Bill Dina Baili Janet Munehiro Chuck Darian M M M M F F F M M F 0201 0202 0209 0203 0208 0206 0207 0204 0205 0210 Sorting depends on an implementation. Class
Background image of page 5

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

View Full DocumentRight Arrow Icon
CSS342: Objects and Classes 6 List Operations Spec. create( ): creates an empty list. destroy( ): destroys a list. insert( int index, Student item): insert an item in front of the position index. Return true in success. remove( int index ): remove the item at the position index. Return true in success. retrieve( int index, Student& item ): retrieve the item at the position index, store it in item, and return true in success. getLength( ): return the number of items in a list. isEmpty( ): return true if the number of items is 0. Class
Background image of page 6
CSS342: Objects and Classes 7 C++ Class destroy( )/destructor insert( ) create( )/constructor retrieve( ) Berger Cioch Olson Erdly Meske Liu McDaniel Fukuda Jackels Smolar Arnold Frank Clark Bill Dina Baili Janet Munehiro Chuck Darian M M M M F F F M M F 0201 0202 0209 0203 0208 0206 0207 0204 0205 0210 Sorting depends on an implementation. data members member functions/methods public private remove( ) getLength( ) isEmpty( ) Utility_func1( ) Utility_func2( ) Class
Background image of page 7

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

View Full DocumentRight Arrow Icon
CSS342: Objects and Classes 8 C++ Header and Implementation File Header File (.h) Write a class specification Summary of the class usage and behavior Public member function prototypes Private data members Private member function prototypes Implementation File (.cpp) Code an implementation of each member function
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/20/2009.

Page1 / 26

Class - CSS342: Objects and Classes Professor: Munehiro...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online