Objects and Classes - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Objects and Classes

Description:

It is a burgundy,'91', Buick, owner: Lackey. Your_car is an object. It is a ... In our discussion the class All_Cars is described by color, year, make, and owner. ... – PowerPoint PPT presentation

Number of Views:95
Avg rating:3.0/5.0
Slides: 14
Provided by: EdwardDon8
Category:
Tags: buick | classes | objects

less

Transcript and Presenter's Notes

Title: Objects and Classes


1
Objects and Classes
  • A very brief first introduction

2
Objects
  • Things we deal with every day are examples of
    objects.
  • My_car is an object. It is a burgundy,91,
    Buick, owner Lackey
  • Your_car is an object. It is a ______, ____,
    ____, _______.
  • My_car and Your_car are just two members of a
    much larger collection of All_Cars.
  • This much larger collection is called a Class.

3
  • In our discussion the class All_Cars is described
    by color, year, make, and owner.
  • There are some operations or functions associate
    with All_Cars that may be useful such as
  • changeOwnerName
  • changeCarColor

4
Class
  • A class defines the types of data we are dealing
    with that are of interest to us. In this case
  • Color
  • Year
  • Make
  • Owner
  • and a class defines the type of things we can do
    with the data like changeCarColor, ..

5
Example 2
  • Your Banner student record is an object. It has
    your name, address, e-mail, courses taken,
    courses you are taking, grades, etc.
  • This is one instance or object in the much larger
    class of LTU_Banner_Students.

6
Describing LTU_Banner_Students
  • Data.
  • Name
  • Address
  • E-mail
  • Courses_taken
  • Current_courses
  • Etc.
  • Thing we can do to the data.
  • changeEmail
  • dropClass
  • many others

7
Question about the class LTU_Banner_Students
  • Is eye color an important characteristic use by
    the University to describe a student?
  • Ans NO
  • It is not meaningful in the Universitys
    application. It is an attribute or characteristic
    that may be important in some other application,
    but not in Banner.

8
Example 3from C
  • objects or things
  • 2
  • 3
  • int x
  • things we can do with the data
  • max(x,31)

9
  • The class is called integers.
  • The things we can do.
  • /
  • -
  • Etc.
  • When a C program contains int x is defining
    the object x which is one member of the class int
    and allows us to do things like or max or .

10
Object
  • An object is one member (or instance) of a
    defined class. An object is a software collection
    of related variables (data) and functions (or
    operations) that can act on those variables.

11
Example of a software circle class and object
  • Example A class called Circle.
  • Data describing all circles.
  • radius (we will use variable r)
  • Functions
  • area(r) .. (which is ? rr)
  • distanceAround(r) .. (2?r)

12
Using the Circle class
  • void main (void)
  • double y 2.77
  • Circle sample1 // creates an object like
    saying int x
  • Circle sample2 // creates another object
  • coutltlt sample1.area(y)ltltendl
  • coutltlt sample2.distanceAround(2y)
  • getchar() return

13
Class
  • A Class is a template for and object. The
    definitions of data and functions that act on the
    data are contained in a class. It is a prototype
    that defines the variables and the functions
    common to all objects belonging to the class.
  • An object is an instance of a class.
Write a Comment
User Comments (0)
About PowerShow.com