Topic#3 - CS162 Topic#3 Lecture Data Abstraction in C Terminology Data Hiding Class Constructors Defining and using functions in classes Where to

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

View Full Document Right Arrow Icon
CS162 - Topic #3 Lecture: Data Abstraction in C++ Terminology Data Hiding Class Constructors Defining and using functions in classes Where to place the class interface and implementation of the member functions Programming Assignment Discussion
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS162 - “ class ” Terminology Class think data type Object instance of a class, e.g., variable Members like structures, the data and functions declared in a class called “data members” and “member functions”
Background image of page 2
CS162 - “ class ” Terminology A class could be a list, a string, a counter, a clock, a bank account, etc. discuss a simple counter class on the board An object is as real as a variable, and gets allocated and deallocated just like variables discuss the similarities of: int i; list j;
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS162 - “ class ” Terminology For the list of videos data type we used last time. ... class list { <--- the data type!!! public: list(); <--- the constructor int add (const video &); 3 member functions int remove (char title[]); int display_all(); private: video my_list[CONST_SIZE]; data members int num_of_videos; }; <--- notice like structures we need a semicolon
Background image of page 4
CS162 - “ class ” Terminology If we examine the previous class, notice that classes are really very similar to structures a class is simply a generalized structure in fact, even though we may not have used structures in this way. .. Structures and Classes are 100% identical except for their default conditions ... by default, all members in a structure are available for use by clients (e.g., main programs); they are public
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS162 - “ class ” Terminology We have seen the use of structures in a more simple context, as we examined with the video struct. It had three members (data members) called title, category, and quantity. They are “public” by default, so all functions that have objects of type video can directly access members by: video object; object.title object.category object.quantity
Background image of page 6
CS162 - “ class ” Terminology This limited use of a structure was appropriate,
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/17/2010 for the course CS 162 taught by Professor Fant during the Spring '08 term at Portland State.

Page1 / 25

Topic#3 - CS162 Topic#3 Lecture Data Abstraction in C Terminology Data Hiding Class Constructors Defining and using functions in classes Where to

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

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