Chapter 10 Classes and Objects In-Depth - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 10 Classes and Objects In-Depth

Description:

A class provides the foundation for creating specific objects, each of which ... At the abstract level, a class can be described as an interface that defines the ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 21
Provided by: andrewst3
Category:

less

Transcript and Presenter's Notes

Title: Chapter 10 Classes and Objects In-Depth


1
Chapter 10Classes and Objects In-Depth
2
Chapter 10
  • A class provides the foundation for creating
    specific objects, each of which shares the
    general attributes, or characteristics, and
    behavior of the class.
  • At the abstract level, a class can be described
    as an interface that defines the behavior of its
    objects.
  • At the implementation level, a class is a
    syntactical unit that describes a set of data and
    related operations that are common to its
    objects.

3
Chapter 10
  • CLASS DECLARATION FORMAT
  • class name
  • //FUNCTION MEMBERS
  • public
  • Function prototypes go here.
  • //DATA MEMBERS
  • private
  • Variable definitions go here.
  • //END CLASS

4
Chapter 10
  • The public class functions form the interface to
    the class and are accessible from outside the
    class. Public functions are used to provide
    access to and manipulate the private class
    members. A private class member is only
    accessible within the class by functions of the
    same class.

5
Chapter 10
  • Encapsulation means to package data and/or
    operations into a single well-defined programming
    unit.

6
Chapter 10
  • Information hiding means that there is a binding
    relationship between the information, or data,
    and its related operations so that operations
    outside the encapsulated unit cannot affect the
    information inside the unit.

7
Chapter 10
  • The Unified Modeling Language, or UML, is a
    technique for analyzing and designing
    object-oriented software.

8
Chapter 10
  • UML diagram for a SavingsAccount class

9
Chapter 10
  • An object is an instance, or specimen, of a given
    class. An object of a given class has the
    structure and behavior defined by the class that
    is common to all objects of the same class.

10
Chapter 10
  • Object Definition Format
  • class name object name

11
Chapter 10
  • A function implementation is the definition of
    the function that includes the function header
    and the body of the function.

12
Chapter 10
  • Format for a Function Implementation
  • return type class name function name
    (parameter listing)
  • //BODY OF FUNCTION GOES HERE
  • //END FUNCTION

13
Chapter 10
  • A constructor is a special class function that is
    used to initialize an object automatically when
    the object is defined.

14
Chapter 10
  • Constructor Format

15
Chapter 10
  • All the member functions of a class carry with
    them an invisible pointer, called this, that
    points to the object that called the function.

16
Chapter 10
  • An access function, sometimes called a get
    function, is a function that returns only the
    values of the private members of an object.

17
Chapter 10
  • A message is a call to a member function.

18
Chapter 10
  • A type cast converts data of one type to a
    different type, temporarily. You can convert data
    of one type to another type by preceding the data
    variable/expression with the type to convert to
    within parentheses like this winPercent
    (double)wins/(wins losses) 100

19
Chapter 10
  • A project file identifies the files that need to
    be compiled and linked to create a given
    executable program.

20
Chapter 10
  • A multi-file Project
Write a Comment
User Comments (0)
About PowerShow.com