Lecture 17 - Defining Classes

Lecture 17 - Defining Classes - Technicalities: Classes,...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Technicalities: Classes, etc. Lecture 23 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/~hkaiser/spring_2011/csc1253.html Abstract This lecture presents language technicalities, mostly related to user defined types; that is, classes and enumerations. 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 2 Overview Classes Implementation and interface Constructors Member functions Enumerations Operator overloading 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 3 Classes The idea: A class directly represents a concept in a program If you can think of it as a separate entity, it is plausible that it could be a class or an object of a class Examples: vector, matrix, input stream, string, FFT, valve controller, robot arm, device driver, picture on screen, dialog box, graph, window, temperature reading, clock A class is a (user-defined) type that specifies how 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 4 Members and member access One way of looking at a class; class X { // this class name is X // data members (they store information) // function members (they do things, using the information) }; Example 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 5 Classes A class X is a user-defined type class X { // this class name is X public : // public members -- thats the interface to users // (accessible by all) // functions // types 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 6 Struct and class Class members are private by default: class X { int mf(); // }; Means class X { 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 7 Struct and class A struct is a class where members are public by default: struct X { int m; // }; Means 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc. 8 Structs // simplest Date (just data) struct Date { int y, m, d; // year, month, day }; Date my_birthday; // a Date variable (object) 11/17/ 2011, Lecture 23 CSC1254, Fall 2011, Technicaliti es: Classes, etc....
View Full Document

Page1 / 30

Lecture 17 - Defining Classes - Technicalities: Classes,...

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

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