CS161_Topic#16

CS161_Topic#16 - CS161 CS161 Introduction to Computer...

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

View Full Document Right Arrow Icon
1 CS161 CS161 Introduction to Introduction to Computer Science Computer Science Topic #16
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS161 Topic #16 2 Today in CS161 Classes What is a class Why would we use them How do we define classes How do we define objects of a class How do we pass objects to functions What is next?
Background image of page 2
CS161 Topic #16 3 What is a Class • Remember, we used a structure to group  different types of data together under a  common name • With a class, we go the next step an  actually define a new data type • With a class, we go beyond grouping  data, and add functions that can work  on that data
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS161 Topic #16 4 What is a Class In reality, we can do the same things with structures and classes, although for style and compatibility it is not recommend Syntactically, structures and classes are 100% the same except for the default conditions (and the keyword “struct” versus “class”) Everything you can do with a class you can do with a structure! However, we should develop a style for when it is best to use a class versus a struct
Background image of page 4
CS161 Topic #16 5 When do we use Classes? • I recommend using structures when you want to  group different types of data together and, to use a class when we are interested in building a new type of data into the language itself
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS161 Topic #16 6 What is a Class First, let’s talk about some terminology
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.

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

Page1 / 19

CS161_Topic#16 - CS161 CS161 Introduction to Computer...

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

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