Classes - PowerPoint PPT Presentation

1 / 85
About This Presentation
Title:

Classes

Description:

Specification and Implementation Files. Client Program ... steering wheel, automatic transmission lever, accelerator pedal and brake pedal) ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 86
Provided by: cecsC
Category:
Tags: classes

less

Transcript and Presenter's Notes

Title: Classes


1
Classes
  • Donna Pompei

2
Introduction
  • Structs
  • Abstract Data Types and Object-Oriented Design
  • Classes
  • Specification and Implementation Files
  • Client Program
  • Object-Oriented Design Using Nouns and Verbs
  • Improvements to the Time Class
  • UML Diagram of the Time Class

3
Structs
  • Two common aggregate (or composite) data
    structures in the C language are arrays and
    structs.
  • An array is designed to contain a collection of
    items that all have the same type.
  • A struct can contain elements that all have the
    same type but typically will contain elements of
    dissimilar types.

4
  • When might we use a struct?
  • Consider a Time object.
  • A Time object may consist of the hour, minute and
    second.
  • In conversation, we speak of the current time but
    in reality we are referring to the current hour,
    minute and second.
  • Arrays and structs have their origin in the C
    language.

5
  • struct Time
  • int hour
  • int minute
  • int second

6
  • The keyword struct indicates the data type is a
    struct (or structure).
  • Time is the new type name that we are creating
    (similar to an int or float except that Time is a
    user-define type).
  • The elements or data members of type Time are
    contained with braces.
  • The semi-colon at the end of the declaration is
    critical. Your program will produce compiler
    error messages without it.
  • Each data member within the struct Time is
    preceded by its own type in this case all have
    type int.

7
  • A data member type could be an array, e.g. an
    array of int, or another struct.
  • However, a data member cannot be a struct with
    the same type name as the name of the struct in
    which it exists.
  • struct myStruct
  • int i
  • myStruct ms // Illegal
  • anotherStruct as // Legal as long as
  • // anotherStruct has
  • // been defined elsewhere

8
  • Though a struct cannot contain a data member with
    the same name as the struct name, it can contain
    a pointer to an element of that struct's name.
  • struct node
  • int i
  • node nodePtr

9
  • Structs do not reserve any space in memory.
  • They are nothing more than a user-defined data
    type.
  • Memory is reserved when a program declares an
    object of the user-defined data type.

10
  • To declare an instance (or object) of type Time
    you would code
  • struct Time
  • int hour
  • int minute
  • int second
  • int main()
  • Time t // Declare an instance t of type Time
  • return 0

11
  • The declaration of instance t causes enough
    contiguous memory to be reserved to store three
    integer values hour, minute and second.
  • hour minute second
  • t

12
  • To access each of the data members, either for
    storing or retrieving values, we use the dot (.)
    operator.
  • The syntax used precedes the dot operator with
    the name of the object and follows the dot
    operator with the member name.
  • To access Time t's data member hour, code
    t.hour.
  • To store 93045 in the instance t and print the
    stored value, code the following

13
  • struct Time
  • int hour
  • int minute
  • int second
  • int main()
  • Time t // Declare an instance t of type Time
  • t.hour 9 // Set t's data member hour to 9
  • t.minute 30 // Set t's data member minute to
    30
  • t.second 45 // Set t's data member second to
    45
  • cout ltlt "The time is " ltlt t.hour ltlt ''
  • ltlt ((t.minute lt 10 ? "0" "")) ltlt t.minute ltlt
    ''
  • ltlt ((t.second lt 10 ? "0" "")) ltlt t.second ltlt
    endl
  • return 0

14
  • C-style structs are a good way to organize
    related data but they have several inherent
    problems.
  • It is possible to have uninitialized data or
    garbage in the data members.
  • Invalid values can be stored directly into the
    data members.
  • In the prior example, it would be possible to
    store 80 into t.minute though 80 is obviously an
    invalid minute.

15
  • Each data member must be printed separately.
  • There is no provision to print the object as a
    unit.
  • It would be much easier to code
  • cout ltlt "The time is " ltlt t ltlt endl

16
  • Structures cannot be compared as a unit.
  • Consider two instances of Time, t1 and t2. To
    determine if t1 was less than t2
  • if (t1.hour lt t2.hour)
  • cout ltlt "t1 is less than t2" ltlt endl
  • else if (t1.hour t2.hour t1.minute lt
    t2.minute)
  • cout ltlt "t1 is less than t2" ltlt endl
  • else if (t1.hour t2.hour t1.minute
    t2.minute
  • t1.second lt t2.second)
  • cout ltlt "t1 is less than t2" ltlt endl
  • else
  • cout ltlt "t1 is not less than t2" ltlt endl

17
  • Wouldn't it be so much easier and understandable
    to code
  • if (t1 lt t2)
  • cout ltlt "t1 is less than t2" ltlt endl
  • else
  • cout ltlt "t1 is not less than t2" ltlt endl

18
  • To print or compare objects rather than
    individual data members is a simple and easy
    process but we need to expand on the idea of
    structs in order to accomplish this.
  • We need to introduce the concept of classes,
    which is a natural extension of structs.
  • But first, we need to understand abstract data
    types and object-oriented design and programming.

19
Abstract Data Types and Object-Oriented Design
  • Object-orientation is a natural way of looking at
    our world.
  • It also allows for an easy transition to
    facilitate writing programs.

20
  • As you drive through your city, you see objects
    all around you--cars, buildings, traffic lights,
    people, babies, etc.
  • You categorize and identify them by their
    attributes and behaviors.
  • If I asked you, "What has four legs, fur, a tail
    and barks?" you would most likely answer, "A
    dog."
  • Attributes four legs, fur, a tail
  • Behavior barks

21
  • Objects may also communicate between each other.
  • A person object may communicate to a dog object
    by giving it a command such as "Fetch."
  • A car responds to the changing colors of a
    traffic light.
  • In object-oriented terminology, this is referred
    to as messaging.

22
  • In this world, there are many dogs, e.g. Lassie,
    Benji, Rin Tin Tin, but they all exhibit the same
    attributes and behaviors that put them into the
    category of dog.
  • However, each of those dogs is a unique instance
    of the category of dog.
  • In object-oriented terminology, we refer to
    Lassie as an object (or instance) of the class
    dog, Benji as an object (or instance) of the
    class dog, etc.

23
  • A primary goal of object-oriented design (OOD) is
    to identify classes using attributes and
    behaviors.
  • A class, also known as an abstract data type
    (ADT), is an abstract description of a
    user-defined data type.
  • It is a description of the attributes (data
    members) of the data type and the operations
    (member functions) that can be performed on those
    data members.

24
  • After the classes are identified and defined, the
    next step is to look for class relationships
    where classes may be related to each other
    through composition or inheritance.

25
  • Composition is referred to as the "has-a"
    relationship.
  • Given two classes, car and radio.
  • Each class has its own respective attributes and
    behaviors.
  • Using the "has-a" test, a "car has a radio".
  • Cannot say that "radio has a car" because that
    doesn't make sense.
  • But "car has a radio" implies that radio is an
    attribute of the class car.

26
  • Inheritance is referred to as the "is-a"
    relationship.
  • A convertible is-a car.
  • Convertible inherits all the attributes
    (manufacturer name, model, etc.) and behaviors
    (stop, start, turn left, turn right, etc.).
  • Convertible also has additional attributes and/or
    behaviors that a car does not have (for example,
    a convertible has a top that goes up and down).
  • The is-a test also tells us the parent (car) and
    the child (convertible) in the inheritance
    relationship.

27
  • An extension of inheritance is multiple
    inheritance.
  • In multiple inheritance relationships, a child
    class has two or more parents.
  • For example, a class called married couple has
    two parent classes, man and woman.

28
  • OOD encapsulates data (attributes) and functions
    (behaviors) into objects the data and the
    objects are closely tied together.
  • A complex number has two attributes the real
    value and the imaginary value.
  • Behaviors involving complex numbers might be
    addition (adding real to real and imaginary to
    imaginary), subtraction, multiplication,
    comparison (equal, less than, greater than),
    display and setting the values of the real and
    imaginary parts.

29
  • In contrast, a fraction has two attributes the
    numerator and the denominator.
  • Similar to a complex number, we can also add
    fractions but fraction addition involves
    converting two fractions so they have a common
    denominator, adding the numerators and then
    reducing the fraction.

30
  • Given two complex numbers, c1 and c2, perform
    addition by coding c1 c2.
  • Addition for two fractions, f1 and f2, would be
    coded the same way, i.e. f1 f2, but the
    addition process would be different than that for
    complex numbers.
  • For display purposes, a complex number might be
    printed in the format 3 4i whereas a fraction
    would be displayed as 3/4.
  • The data (attributes) and functions (behaviors)
    are encapsulated within the object. The behavior
    (or function) that is invoked depends on what the
    object is.

31
  • Classes provide the capability of information
    hiding to hide the unnecessary details of a class
    implementation from those who have no need or
    desire to see them.
  • The implementation details are hidden from the
    client programmer within the class.

32
  • "Methods" is an object-oriented term that is used
    in lieu of the word "functions."
  • A method prototype (similar to a function
    prototype) provides
  • The name of the method.
  • Its return type.
  • Function parameters (if any)
  • Pre- and post-condition comments.
  • This is referred to as the class interface.

33
  • The information contained in the class interface
    should be all that is necessary for a client
    programmer or another class object to invoke the
    methods contained within the class.
  • A good analogy for information hiding is that it
    is possible to drive a car as long as the driver
    is familiar with the car's interface (key or
    ignition system, steering wheel, automatic
    transmission lever, accelerator pedal and brake
    pedal).
  • The driver does not need to know the details of
    how the electrical, engine and transmission
    systems work in order to drive the car.

34
Classes
  • Using the struct Time, it is possible to store
    invalid values in the data members hour, minute
    and second.
  • We will now create a class for the abstract data
    type Time.
  • Use public and private member access specifiers
    to guarantee that the data members hour, minute
    and second will never contain invalid values.

35
  • Our class interface (also known as the
    specification file) for Time will look like the
    following slide

36
  • // Fig. 3.1 - time.h Specification file for the
    Time class
  • pragma once
  • class Time
  • public
  • Time()
  • // Post-condition 0 will be stored in hour,
    minute,
  • // and second
  • void setHour(int h)
  • // Pre-condition h must be in the range 0 - 23
  • // Post-condition h will be stored in hour if
    valid
  • // otherwise 0 will be stored in hour
  • void setMinute(int m)
  • // Pre-condition m must be in the range 0 - 59
  • // Post-condition m will be stored in minute if
    valid
  • // otherwise 0 will be stored in minute
  • void setSecond(int s)
  • // Pre-condition s must be in the range 0 - 59

37
  • The specification (header) file time.h contains
    the pragma once directive.
  • This directive informs the compiler to process
    the header file only once even if it is included
    in more than one file within a project.
  • Omitting this directive can result in a compiler
    error if a class definition is included more than
    once.
  • You should code pragma once at the top of each
    of your specification (header) files.

38
  • A Time object has attributes (or data members)
    hour, minute and second.
  • From a behavior standpoint, we would also like to
    be able to store values into hour, minute and
    second (among other behaviors such as value
    retrieval).
  • We encapsulate within the Time class the data
    members hour, minute and second along with the
    member functions to store legitimate values into
    those data members.

39
  • Using the Time struct, if we had a Time object
    t, we could store an invalid value into any of
    the data members by coding
  • t.hour 50 // Illegal hour

40
  • One of the primary objectives of object-oriented
    programming is to insure that all class data
    members are in a safe state at all times.
  • Accomplished by using the member access
    specifiers public and private.
  • Make the data members private by placing the word
    private followed by a colon () before them.
  • Once a data member (or member function) is
    declared private, the only items that can access
    it directly are member functions of that class or
    friend functions of that class.
  • Public members can be accessed by the client
    program, the class itself and other classes.

41
  • So then how can we store a value into Time's hour
    if it is declared to be private?
  • We call a public member function that must
    validate the value prior to storing it into the
    private data member.
  • It is the responsibility of all member functions
    of a class to guarantee that no invalid value
    will ever be stored in the class's data members.

42
  • Too many times, a programmer creates a class and
    then either
  • makes the data members public or
  • does not put error checking code into any of the
    functions that can store values in the data
    members.
  • One of the primary objectives of object-oriented
    programming is to guarantee that all data members
    are kept in a safe state at all times.
  • This fact cannot be emphasized enough.

43
  • A good programming practice is to place all
    public members first in the class definition,
    followed by the private members.
  • When a programmer is looking at the
    specification, the only thing he/she has access
    to is the public members.
  • For ease of readability, there is no point of
    putting the private members first because the
    programmer will not have access to them.

44
  • Another good programming practice is to make all
    data members private.
  • Most functions will be public but a few utility
    functions (functions used by the class but not by
    the client program) will be private.

45
  • A few rules to consider regarding member access
    specifiers
  • If a member access specifier is not declared
    immediately after the first brace of the class,
    all member functions and data members are
    considered private until the ending brace or a
    member access specifier is encountered.
  • Member functions and data members will have the
    access of the member specifier immediately
    preceding it.
  • It is possible to have multiple declarations of
    public and private within a class but a good
    programming practice is to declare each specifier
    only once, with public preceding private.

46
  • Mutator methods change the values stored in the
    data members.
  • The public functions that store (or set values)
    into the private data members are mutator
    methods.
  • It is the responsibility of those functions to
    guarantee that the data members will always
    remain in a safe state.

47
  • An accessor method accesses the values contained
    in the data members but does not change them.
  • The display method is an accessor method.
  • If the word const appears at the end of a class
    member method, it indicates that the method is
    not allowed to change the values in the data
    members of the class object that called the
    function.

48
  • The following function prototype is a very
    special one, known as a constructor .
  • Time()
  • It does not have a return type.
  • Its name is the same name of the class.
  • Its purpose is to initialize the values of the
    data members to a safe state.

49
  • As a programmer, you typically do not call the
    constructor explicitly it is invoked implicitly
    when an object of the class is declared.
  • int main()
  • Time lunchTime
  • return 0
  • The statement, Time lunchTime
  • Invokes the constructor Time()
  • Statically reserves space in memory for the
    lunchTime object.

50
  • The constructor Time() is called the default
    constructor because it does not require any
    arguments.
  • If you do not code a default constructor
  • The compiler will automatically provide one
  • It will not guarantee proper initialization of
    the class's data members.
  • You should always code your own constructor to
    insure that the data members are initialized to a
    safe state.

51
  • It is also possible to code other constructors,
    either in lieu of the default constructor or in
    addition to the default constructor.
  • These constructors (which have arguments) are
    known as conversion constructors.
  • If a conversion constructor is coded but no
    default constructor is present, the compiler will
    not automatically provide a default constructor.

52
  • An example of a conversion constructor prototype
    might be
  • Time(int h, int m, int s)
  • // Pre-condition Arguments must be in the
  • // following range
  • // h (hour) 0-23
  • // m (minute) 0 - 59
  • // s (second) 0 - 59
  • // Post-condition If an argument is out of
    range,
  • // the respective data member will be set to 0

53
Specification and Implementation Files
  • The time.h file in the previous section is
    referred to as a specification file.
  • The specification file contains the class
    declaration which is the only thing a client
    programmer needs to utilize the class.
  • However, code must be provided for the method
    prototypes contained in the class declaration and
    that is done within the implementation file.

54
  • Typically, each class contained in its own
    specification file will have a matching
    implementation file.
  • Standards dictate that if a class is called Time,
    its specification file will be time.h and its
    implementation file will be time.cpp.
  • For the time.h specification file in the previous
    section, we might code the following
    implementation file

55
  • // Fig. 3.2 - time.cpp Implementation file for
    the Time class
  • include "stdafx.h"
  • include "time.h"
  • include ltiostreamgt
  • using namespace std
  • TimeTime()
  • // Post-condition 0 will be stored in hour,
    minute,
  • // and second
  • hour 0
  • minute 0
  • second 0
  • void TimesetHour(int h)
  • // Pre-condition h must be in the range 0 - 23
  • // Post-condition h will be stored in hour if
    valid

56
  • void TimesetMinute(int m)
  • // Pre-condition m must be in the range 0 - 59
  • // Post-condition m will be stored in minute if
    valid
  • // otherwise 0 will be stored in minute
  • if (m lt 0 m gt 59)
  • minute 0
  • cerr ltlt "Minute is not valid--will be set to 0"
    ltlt endl
  • else
  • minute m
  • void TimesetSecond(int s)
  • // Pre-condition s must be in the range 0 - 59
  • // Post-condition s will be stored in second if
    valid
  • // otherwise 0 will be stored in second
  • if (s lt 0 s gt 59)

57
  • The include "stdafx.h" directive directs the
    compiler to include the contents of the file
    stdafx.h (a file generated by Visual Studio .NET)
    into the compilation process.
  • The file stdafx.h is an include file for standard
    system include files and for project-specific
    include files that are used frequently but are
    changed infrequently.
  • Without the preprocessor directive to include
    time.h, the compiler would generate error
    messages that the function definitions in
    time.cpp are missing their function prototypes.
  • The header file iostream is included (line 6)
    because the method display outputs the values
    contained in the data members.

58
  • The full implementation of member functions in
    the implementation file typically includes the
    following items
  • The member function's return type.
  • The class name (so that the method can be
    associated with the class within which it
    resides).
  • The scope resolution operator (two consecutive
    colons).
  • The member function name.
  • The parameters contained between two parentheses.
  • A block that delimits the statements of the
    member function.

59
  • The syntax used to define a function within the
    implementation file is
  • return-type class-namemember-function-name(param
    eter list)
  • declarations
  • statements

60
  • Though hour, minute and second are declared
    private within the class declaration, all member
    functions of the Time class have access to the
    data members and can store and retrieve values
    from them.
  • The private protection extends only to any code
    beyond the class itself.
  • A client program that uses the class would not be
    able to store values directly into the data
    members.
  • It would need to invoke the public member
    functions to store any values.

61
  • The compiler distinguishes between const and
    non-constant functions.
  • If you declare in the function prototype that the
    function is constant and you code the function
    definition in the implementation file without the
    word const, the compiler will indicate that the
    non-constant function definition does not have a
    non-constant function prototype.
  • When coding class functions that are accessor
    functions, you should always use the word const
    following the parameter list.

62
Client Program
  • Client programs are those programs that invoke
    the methods contained within the class(es).
  • Typically, client programs are the programs that
    contain the main() function.

63
  • An important item to note here is that when
    designing and writing the code for a class, the
    code should be written so that any client program
    can use the class.
  • A key to object-oriented programming is
    reusability.
  • Class code ideally should be able to be used by
    any number of client programs.
  • A sample client program that uses the Time class
    might look like the following slide

64
  • include "stdafx.h"
  • include "time.h"
  • include ltiostreamgt
  • using namespace std
  • int main()
  • Time lunchTime // Object lunchTime with hour,
  • // minute and second set to 0
  • Time dinnerTime // Object dinnerTime with
    hour,
  • // minute and second set to 0
  • cout ltlt "Lunch time is " // Display lunch time
  • lunchTime.display()
  • cout ltlt endl
  • cout ltlt "Dinner time is " // Display dinner
    time
  • dinnerTime.display()
  • cout ltlt endl
  • lunchTime.setHour(12) // Set lunchTime hour to
    12

65
  • The following would be displayed in the console
    window when the client program is executed
  • Lunch time is 00000
  • Dinner time is 00000
  • Lunch time is 121530
  • Second is not valid--will be set to 0
  • Dinner time is 182000
  • Press any key to continue . . .

66
  • When lunchTime is declared, sufficient contiguous
    space is reserved in memory to store three
    integer values hour, minute and second.
  • Similarly, when dinnerTime is declared, space is
    also reserved for dinnerTime's hour, minute and
    second.
  • At the time of declaration of lunchTime and
    dinnerTime, the constructor for each object is
    called to initialize the integer values contained
    in memory.

67
  • After lunchTime and dinnerTime are declared and
    initialized, the two objects are considered to be
    in a "safe state," i.e. they do not contain
    garbage or any illegitimate values.
  • After declaration, the objects stored in memory
    will look like the following slide

68
  • hour minute second
  • lunchTime
  • hour minute second
  • dinnerTime

0
0
0
0
0
0
69
  • When calling the function setHour, the statement
    on line 16 is
  • lunchTime.setHour(12)
  • Though it looks like the function setHour is only
    being called with one argument, the value 12, in
    reality the function is being called with two
    arguments lunchTime and the value 12.
  • The object that precedes the dot operator is
    called the implicit argument.
  • Any arguments that are between the parentheses
    are called the explicit argument(s).

70
  • hour minute second
  • lunchTime
  • hour minute second
  • dinnerTime

12
15
30
0
0
0
71
  • The program attempts to assign the value of 80 to
    dinnerTime's data member second.
  • The setSecond function displays an error message
    that the 80 is an invalid value for second and
    stores the value of 0 into the data member
    second.
  • It would be nice if the set function could
    reprompt the user for the correct value but many
    times, client programs do not directly interface
    to a user they may be working with file
    input/output for example.
  • An error message is displayed and a predetermined
    default value is assigned.

72
  • hour minute second
  • lunchTime
  • hour minute second
  • dinnerTime

12
15
30
18
20
0
73
Object-Oriented Design Using Nouns and Verbs
  • Suppose you were given the following problem
    specification
  • Military time consists of hour, minute and
    second based on a 24-hour clock. Your abstract
    data type time should be able to independently
    set the hour, minute and second as well as
    display the time in military format hhmmss.

74
  • Programmers use the noun-verb classification to
    help them identify class names, data members and
    member functions (or methods).
  • When reading the problem specification, circle
    the nouns and underline the verbs.

75
  • Using the above example, we have
  • Nouns Verbs
  • time consists (has-a)
  • clock set
  • hour display
  • minute
  • second

76
  • Nouns will either indicate your class names, data
    member names or be disregarded.
  • Verbs will indicate your functions.
  • As we look at the nouns, time appears to be more
    significant than the other nouns.
  • Consider it as a potential class name.
  • Hour, minute and second are not significant
    enough to warrant their own classes.
  • Because of the has-a relationship which
    indicates composition, we can say that the class
    Time has data members hour, minute and second.
  • Clock is also a noun but can be disregarded.

77
  • The verb consists translates into the has-a
    relationship.
  • The verb set is used in the context set hour, set
    minute and set second.
  • The verb (sometimes used in conjunction with a
    noun) provides a good name for our class
    functions, in this case setHour, setMinute and
    setSecond.
  • Our final verb, display is sufficient enough for
    its own function name or could be combined with
    the word time to get displayTime.

78
Improvements to the Time Class
  • Our Time class has the ability to independently
    set the data members but a client program cannot
    retrieve the values contained in hour, minute and
    second.
  • Perhaps I wish to write a client program that
    will create two objects, lunch time and dinner
    time and also determine the time difference
    between the two times.
  • As the Time class exists now, I would be unable
    to do that.

79
  • Basic components of a class are
  • constructor(s)
  • set (mutator) functions
  • get (accessor) functions
  • any other functions the class might need.
  • By modifying the Time class to the following
    slides, we make our class more versatile.

80
  • // Fig. 3.4 - time.h Specification file for the
    Time class
  • pragma once
  • class Time
  • public
  • Time()
  • // Post-condition 0 will be stored in hour,
    minute,
  • // and second
  • void setHour(int h)
  • // Pre-condition h must be in the range 0 - 23
  • // Post-condition h will be stored in hour if
    valid
  • // otherwise 0 will be stored in hour
  • void setMinute(int m)
  • // Pre-condition m must be in the range 0 - 59
  • // Post-condition m will be stored in minute if
    valid
  • // otherwise 0 will be stored in minute
  • void setSecond(int s)
  • // Pre-condition s must be in the range 0 - 59

81
  • // Fig. 3.5 - time.cpp Implementation file for
    the Time class
  • //
  • include "stdafx.h"
  • include "time.h"
  • include ltiostreamgt
  • using namespace std
  • TimeTime()
  • // Post-condition 0 will be stored in hour,
    minute,
  • // and second
  • hour 0
  • minute 0
  • second 0
  • void TimesetHour(int h)
  • // Pre-condition h must be in the range 0 - 23
  • // Post-condition h will be stored in hour if
    valid

82
  • int TimegetHour() const
  • // Pre-condition None
  • // Post-condition hour will be returned
  • return hour
  • int TimegetMinute() const
  • // Pre-condition None
  • // Post-condition minute will be returned
  • return minute
  • int TimegetSecond() const
  • // Pre-condition None
  • // Post-condition second will be returned
  • return second

83
UML Diagram of the Time Class
  • A class, its data members and member functions
    can be diagrammed using the Unified Modeling
    Language (UML) notation.

84
  • The class diagram consists of three parts
  • The top section is the class name.
  • The middle section contains the class's data
    members.
  • The bottom section contains the member functions.
  • If a class member is preceded by the symbol , it
    means that the class member is public.
  • A minus symbol (-) indicates the class member is
    private.

85
Time
- hour int - minute int - second int
Time() setHour(int h) void setMinute(int
m) void setSecond(int s) void getHour()
const int getMinute() const int
getSecond() const int display() const void
Write a Comment
User Comments (0)
About PowerShow.com