{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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?
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
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

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

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern