Академический Документы
Профессиональный Документы
Культура Документы
Andrew Davison
Noppadon Kamolvilassatian
Department of Computer Engineering
Prince of Songkla University
Contents
Interface
ADT
Implementation
client
use
client
manufacturers
responsibility
4
Benefits
Manufacturer Benefits:
easy to modify, maintain
profitable
reusable
Client Benefits:
No
makes use of
a part of
a specialisation of
a generalisation of
etc
C and C++
10
Time {
hour;
minute;
second;
//
//
//
//
structure definition
0-23
0-59
0-59
// prototype
// prototype
11
main()
{
Time dinnerTime;
// set members to
dinnerTime.hour =
dinnerTime.minute
dinnerTime.second
12
// set members to
dinnerTime.hour =
dinnerTime.minute
dinnerTime.second
invalid values
29;
= 73;
= 103;
13
14
15
Comments
18
20
21
Output
Comments
Time sunset,
arrayOfTimes[5],
*pointerToTime,
24
6. Using Constructors
Interface
Time();
Time(int hr, int min, int sec);
Implementation
Time::Time()
{ hour = minute = second = 0; }
Time::Time(int hr, int min, int sec)
{ setTime(hr, min, sec); }
25
Use:
Time t1;
Time t2(08,15,04);
26
27