Introduction to Structured Data Types and Classes

Slides:



Advertisements
Similar presentations
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
Advertisements

1 Chapter Structured Types, Data Abstraction and Classes Dale/Weems.
Inheritance and Composition (aka containment) Textbook Chapter –
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
1 Chapter 6 Object-Oriented Software Development.
1 Lecture 29 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
Chapter 11: Classes and Data Abstraction
1 Abstract Data Type (ADT) a data type whose properties (domain and operations) are specified (what) independently of any particular implementation (how)
1 Structured Types, Data Abstraction and Classes.
1 Chapter 14 Object-Oriented Software Development Dale/Weems/Headington.
SEN 909 OO Programming in C++ Final Exam Multiple choice, True/False and some minimal programming will be required.
Chapter 11: Classes and Data Abstraction. C++ Programming: Program Design Including Data Structures, Fourth Edition2 Objectives In this chapter, you will:
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Microsoft Visual C++.NET Chapter 51 Introduction to Classes.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
1 Chapter Structured Types, Data Abstraction and Classes Dale/Weems.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
CLASSES : A DEEPER LOOK Chapter 9 Part I 1. 2 OBJECTIVES In this chapter you will learn: How to use a preprocessor wrapper to prevent multiple definition.
1 Structural Types, Data Abstractions and Classes.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
1 Final Exam Tues 3/16/10 (2-3:50) (Same classroom) Old Textbook - Chapters 11-16, 18 Focus is on 15, 16 and 18 Final Exam Tues 3/16/10 (2-3:50) (Same.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 05: Classes and Data Abstraction.
1 Final Exam 20 Questions Final Exam 20 Questions Multiple choice and some minimal programming will be required.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
Programming Fundamentals1 Chapter 7 INTRODUCTION TO CLASSES.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
1 Classes and Data Abstraction Chapter What a Class ! ! Specification and implementation Private and public elements Declaring classes data and.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
1 Structured Types, Data Abstraction and Classes.
Chapter 12 Classes and Abstraction
Procedural and Object-Oriented Programming
Classes C++ representation of an object
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
chapter 11 Structured Types, Data Abstraction, and Classes
Chapter 7: Introduction to Classes and Objects
Dale/Weems/Headington
Abstract Data Types Programmer-created data types that specify
Friend Class Friend Class A friend class can access private and protected members of other class in which it is declared as friend. It is sometimes useful.
Review: Two Programming Paradigms
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Introduction to Classes
Chapter Structured Types, Data Abstraction and Classes
More about OOP and ADTs Classes
CS212: Object Oriented Analysis and Design
CS148 Introduction to Programming II
Introduction to Classes
Classes and Data Abstraction
CS212: Object Oriented Analysis and Design
Chapter 9 Classes: A Deeper Look, Part 1
More about OOP and ADTs Classes
Introduction to Classes and Objects
Classes and Objects.
Chapter 14 Object-Oriented Software Development
Classes C++ representation of an object
Chapter 9 Introduction To Classes
More C++ Classes Systems Programming.
Introduction to Classes and Objects
Presentation transcript:

Introduction to Structured Data Types and Classes A. Berrached@UHD Intro to structs & classes

Objectives In this chapter you will learn: About structured data types and C++ structs About object-oriented programming and classes About information hiding How to use access specifiers About interface and implementation files How to prevent multiple inclusion How to work with member functions A. Berrached@UHD Intro to structs & classes

C++ Data Types simple structured address integral enum floating float double long double array struct union class char short int long bool address pointer reference A. Berrached@UHD Intro to structs & classes

Structured Data Type A structured data type is a type in which each value is a collection of component items. the entire collection has a single name each component can be accessed individually A. Berrached@UHD Intro to structs & classes

C++ Structured Type often we have related information of various types that we’d like to store together for convenient access under the same identifier, for example . . . Define a data types to represent time Hours, mins, & seconds A. Berrached@UHD Intro to structs & classes

Several Possible Representations of TimeType 3 int variables 3 strings 3-element int array actual choice of representation depends on time, space, and algorithms needed to implement operations 10 45 27 “10” “45” “27” 10 45 27 A. Berrached@UHD Intro to structs & classes

Some Possible Representations of ComplexNumberType struct with 2 float members 2-element float array -16.2 5.8 .real .imag -16.2 5.8 A. Berrached@UHD Intro to structs & classes

struct TimeType struct TimeType // declares a struct data type does not // allocate memory { int hrs ; // struct members int mins ; int secs ; } ; TimeType StartTime ; // declare variables of TimeType TimeType EndTime = {12, 0, 0}; // initializer list 8 A. Berrached@UHD Intro to structs & classes

struct type Declaration SYNTAX struct TypeName // does not allocate memory { MemberList } ; MemberList SYNTAX DataType MemberName ; . A. Berrached@UHD Intro to structs & classes

struct type Declaration The struct declaration creates a new data type and names the members of the struct. A struct declaration creates a new data type  a user-defined data type. It does not allocate memory for any variables of that type! You still need to declare your struct variables. A. Berrached@UHD Intro to structs & classes

More about struct type declarations If the struct type declaration precedes all functions it will be visible throughout the rest of the file. If it is placed within a function, only that function can use it. It is common to place struct type declarations with TypeNames in a (.h) header file and #include that file. It is possible for members of different struct types to have the same identifiers. Also a non-struct variable may have the same identifier as a structure member. A. Berrached@UHD Intro to structs & classes

Accessing struct Members Dot ( period ) is the member selection operator. After the struct type declaration, the various members can be used in your program only when they are preceded by a struct variable name and a dot. Note: initial member values are unknown EXAMPLES StartTime.hrs = 5; EndTime.mins = 29; cin >> EndTime.hrs; A. Berrached@UHD Intro to structs & classes

Aggregate Operation is an operation on a data structure as a whole, as opposed to an operation on an individual component of the data structure Allow use of a struct variable as a single unit A. Berrached@UHD Intro to structs & classes

Aggregate struct Operations Operations valid on an entire struct type variable: Assignment to another struct variable of same type, Pass to a function as argument (by value or by reference), Return as value of a function I/O, arithmetic, and comparisons of entire struct variables are NOT ALLOWED! Can be defined using functions A. Berrached@UHD Intro to structs & classes

Defining Aggregate struct Operations void WriteOut( /* in */ TimeType thisTime) // outputs values of all members of thisTime in the format hrs:mins:secs // Precondition: all members of thisTime are assigned // Postcondition: all members have been written out { cout <<thisTime.hrs <<“:” << thisTime.mins ; cout << “:”<< thisTime.secs << endl; } A. Berrached@UHD Intro to structs & classes

Structs: good or bad? + Allow representation of complex data that consists of several related fields that are of different types Initialization (or lack of it) can cause problems Only 3 aggregate ops are predefined, any other op must be defined as a separate function Functions that operate on struct are not textually related to the type definition Not access protection to data members A. Berrached@UHD Intro to structs & classes

Abstraction is the separation of the essential qualities of an object from the details of how it works or is composed focuses on what, not how is necessary for managing large, complex software projects A. Berrached@UHD Intro to structs & classes

Control Abstraction separates the logical properties of an action from its implementation . Search (list, item, length, where, found); the function call depends on the function’s specification (description), not its implementation (algorithm) A. Berrached@UHD Intro to structs & classes

Data Abstraction LOGICAL PROPERTIES IMPLEMENTATION separates the logical properties of a data type from its implementation LOGICAL PROPERTIES IMPLEMENTATION What are the possible values? How can this be done in C++? What operations will be needed? How can data types be used? A. Berrached@UHD Intro to structs & classes

Data Type set of values allowable operations (domain) on those values FOR EXAMPLE, data type int has domain -32768 . . . 32767 operations +, -, *, /, %, >>, << A. Berrached@UHD Intro to structs & classes

Abstract Data Type (ADT) a data type whose properties are specified (what) independently of any particular implementation (how) Data type properties include both a domain and a set of allowable operations FOR EXAMPLE . . . A. Berrached@UHD Intro to structs & classes

ADT Specification Example TYPE TimeType DOMAIN Each TimeType value is a time in hours, minutes, and seconds. OPERATIONS Set the time Print the time Increment by one second Compare 2 times for equality Determine if one time is “less than” another A. Berrached@UHD Intro to structs & classes

ADT Implementation means choosing a specific data representation for the abstract data using data types that already exist (built-in or programmer-defined) writing functions for each allowable operation A. Berrached@UHD Intro to structs & classes

Object-Oriented Programming and Classes C++ allows the programmer to create Abstract Data Types using classes. In general, classes form the basis of object- oriented programming Example: lets create a new ADT for TimeType using a C++ class A. Berrached@UHD Intro to structs & classes

class TimeType Specification // SPECIFICATION FILE ( timetype.h ) class TimeType // declares a class data type { // does not allocate memory public : // 7 public function members int GetHrs() const; int GetMins() const; int GetSecs() const; void Set ( int hours , int mins , int secs ) ; void Increment ( ) ; void Write ( ) const ; bool LessThan ( TimeType otherTime ) const ; private : // 3 private data members int hrs ; int mins ; int secs ; } ; A. Berrached@UHD Intro to structs & classes

Classes In C++ programming, classes are data structures that contain data members along with function members (also called member functions or methods) The data members define the domain i.e. set of values that objects of that type can take. The member functions define the allowable operations that can be used to manipulate objects of that type. A class encapsulates all the elements of an ADT in a single units. Note: Functions that are not part of a class are referred to as global functions A. Berrached@UHD Intro to structs & classes

Classes Class definition = class specification + class implementation declaration as in slide 25 Class implementation: defines each member function that is declared in the class specification Client programs: Programs that declare and use objects of the defined class Client programs must include, using an #include directive, the specification file of the class TimeType T; A. Berrached@UHD Intro to structs & classes

Implementation of TimeType Member Functions #include “ timetype.h” // Specification file #include <iostream> . . . void TimeType :: Set ( int H, int M, int S) // Postcondition: data members are assigned new values as follows: // hrs = H, mins= M, and secs= S { hrs = H; mins = M; secs = S; } A. Berrached@UHD Intro to structs & classes

Member Selection Operator Member selection operator is used to access class members: T.hrs = 20; T.Write(); Classes allow the programmer to define different types of accessibility to the members of the class. A. Berrached@UHD Intro to structs & classes

Information Hiding The principle of information hiding states that any class members that other programmers, sometimes called clients, do not need to access or know about should be hidden Information hiding helps minimize the amount of information that needs to pass in and out of an object, which helps increase program speed and efficiency Information hiding reduces the complexity of the code that clients see, allowing them to concentrate on the task of integrating an object into their programs A. Berrached@UHD Intro to structs & classes

Access Specifiers The first step in hiding class information is to set access specifiers for class members Access specifiers control a client’s access to individual data members and member functions There are four levels of access specifiers: public, private, protected, and friend The public access specifier allows anyone to call a class’s member function or to modify a data member A. Berrached@UHD Intro to structs & classes

Access Specifiers The private access specifier prevents clients from calling member functions or accessing data members and is one of the key elements in information hiding Example: assume in a client program we have TimeType T; T.hrs = 8; error because hrs is declared to be private T.set(8, 30, 48);  OK because member function set() is declared public. A. Berrached@UHD Intro to structs & classes

Access Specifiers An access specifier that is placed on a line by itself followed by a colon is called an access label Access to classes is private by default Access to structs is public by default Accessor functions are public member functions that a client can call to retrieve or modify the value of a data member Because accessor functions often begin with the words get or set, they are also referred to as get or set functions A. Berrached@UHD Intro to structs & classes

TimeType Class Instance Diagrams currentTime endTime Private data: hrs mins secs Set Increment Write LessThan GetHrs 17 58 2 GetMins GetSecs Private data: hrs mins secs Set Increment Write LessThan GetHrs 19 30 GetMins GetSecs A. Berrached@UHD Intro to structs & classes

Information Hiding Class implementation details are hidden from the client’s view. This is called information hiding. Public functions of a class provide the interface between the client code and the class objects. client code abstraction barrier specification implementation A. Berrached@UHD Intro to structs & classes

Interface and Implementation Files Interface code refers to the data member and member function declarations inside a class definition’s braces Interface code does not usually contain definitions for member functions, nor does it usually assign values to the data members. Interface code is generally placed in a header file with a .h extension Implementation code refers to a class’s function definitions and any code that assigns values to a class’s data members Implementation code is placed in .cpp files Implementation code must have access to the class specification by using a #include directive C++ source files are distributed in compiled format, whereas header files are distributed as plain text files Interface code is the only code that can be seen by a user of the class A. Berrached@UHD Intro to structs & classes

2 Separate Files Generally Used to Define a class // SPECIFICATION FILE ( timetype .h ) // Specifies the data and function members. class TimeType { public: . . . private: } ; // IMPLEMENTATION FILE ( timetype.cpp ) // Implements the TimeType member functions. A. Berrached@UHD Intro to structs & classes

Implementation File for TimeType // IMPLEMENTATION FILE ( timetype.cpp ) // Implements the TimeType member functions. #include “ timetype.h” // also must appear in client code #include <iostream> . . . bool TimeType :: Equal ( /* in */ TimeType otherTime ) const // Postcondition: // Function value == true, if this time equals otherTime // == false , otherwise { return ( (hrs == otherTime.hrs) && (mins == otherTime.mins) && (secs == otherTime.secs) ) ; } .............. …………. A. Berrached@UHD Intro to structs & classes

Example Client Code Using TimeType #include “timetype.h” // includes specification of the class using namespace std ; int main ( ) { TimeType currentTime ; // declares 2 objects of TimeType TimeType endTime ; bool done = false ; currentTime.Set ( 5, 30, 0 ) ; endTime.Set ( 18, 30, 0 ) ; while ( ! done ) { . . . currentTime.Increment ( ) ; if ( currentTime.Equal ( endTime ) ) done = true ; } ; } A. Berrached@UHD Intro to structs & classes 39

Separate Compilation and Linking of Files specification file main program timetype.h implementation file client.cpp timetype.cpp #include “timetype.h” Compiler Compiler client.obj timetype.obj Linker client.exe A. Berrached@UHD Intro to structs & classes

Modifying a Class When you modify a class, interface code, such as class member declarations, should change the least The implementation code normally changes the most when you modify a class This rule of thumb is not carved in stone because you may find it necessary to drastically modify your class’s interface A. Berrached@UHD Intro to structs & classes

Modifying a Class But for the most part, the implementation is what will change No matter what changes you make to your implementation code, the changes will be invisible to clients if their only entry point into your code is the interface—provided that the interface stays the same A. Berrached@UHD Intro to structs & classes

Avoiding Multiple Inclusion of Header Files often several program files use the same header file containing typedef statements, constants, or class type declarations--but, it is a compile-time error to define the same identifier twice this preprocessor directive syntax is used to avoid the compilation error that would otherwise occur from multiple declarations of the same class #ifndef Preprocessor_Identifier #define Preprocessor_Identifier . . // class declaration #endif A. Berrached@UHD Intro to structs & classes

Example Using Preprocessor Directive #ifndef // timetype .h FOR COMPILATION THE CLASS DECLARATION IN // SPECIFICATION FILE FILE timetype.h WILL BE INCLUDED ONLY ONCE #ifndef TIME_H #define TIME_H // timetype .cpp // client.cpp // IMPLEMENTATION FILE // Appointment program class TimeType { #include “timetype.h” #include “timetype.h” public: . . . . . . int main ( void ) { private: . . . . . . } ; #endif A. Berrached@UHD Intro to structs & classes

Visual C++ pragma once Directive The pragma once directive instructs the compiler to include a header file only once, no matter how many times it encounters an #include statements for that header in other C++ files in the project Supported in Visual C++ only. A. Berrached@UHD Intro to structs & classes

Visual C++ pragma once Directive // timetype .h // SPECIFICATION FILE #pragma once // timetype .cpp // client.cpp // IMPLEMENTATION FILE // Appointment program class TimeType { #include “timetype.h” #include “timetype.h” public: . . . . . . int main ( void ) { private: . . . . . . } ; A. Berrached@UHD Intro to structs & classes

Scope Resolution Operator ( :: ) C++ programs typically use several class types different classes can have member functions with the same name, like Write( ) Functions from several classes can be in the same file. Some functions may also be global functions in the implementation file, the scope resolution operator is used in the heading before the function member’s name to specify its class void TimeType :: Write ( ) const { . . . } A. Berrached@UHD Intro to structs & classes

Use of const with Member Functions when a member function does not modify the private data members of the class, use const in both the function prototype (in specification file) and the heading of the function definition (in implementation file) void TimeType :: Write ( ) const { . . . } A. Berrached@UHD Intro to structs & classes

Example Using const with a Member Function void TimeType :: Write ( ) const // Precondition: data members have been assigned values // Postcondition: Time has been output in form HH:MM:SS { if ( hrs < 10 ) cout << ‘0’ ; cout << hrs << ‘:’ ; if ( mins < 10 ) cout << mins << ‘:’ ; if ( secs < 10 ) cout << secs ; } A. Berrached@UHD Intro to structs & classes 49

Inline Functions Functions defined inside the class body in an interface file are called inline functions To conform to information-hiding techniques, only the shortest function definitions, such as accessor functions, should be added to the interface file A. Berrached@UHD Intro to structs & classes

Inline Functions A. Berrached@UHD Intro to structs & classes // SPECIFICATION FILE ( timetype.h ) class TimeType // declares a class data type { // does not allocate memory public : // 7 public function members int GetHrs() const { return hrs; } ; int GetMins() const {return mins;} ; int GetSecs() const ; void Set ( int h , int m , int s ) ; void Increment ( ) ; void Write ( ) const { cout <<hrs<<“:”<<mins<<“:”<<secs<<endl; } ; bool LessThan ( TimeType otherTime ) const ; private : // 3 private data members int hrs ; int mins ; int secs ; A. Berrached@UHD Intro to structs & classes

Inline Functions A. Berrached@UHD Intro to structs & classes // SPECIFICATION FILE ( timetype.h ) class TimeType // declares a class data type { // does not allocate memory public : // 7 public function members int GetHrs() const { return hrs; } ; int GetMins() const {return mins;} ; int GetSecs() const ; void Set ( int h , int m , int s ) ; void Increment ( ) ; void Write ( ) const; bool LessThan ( TimeType otherTime ) const ; private : // 3 private data members int hrs ; int mins ; int secs ; } ; inline void TimeType::Write ( ) const { cout <<hrs<<“:”<<mins<<“:”<<secs<<endl; A. Berrached@UHD Intro to structs & classes

Implementation--Increment void TimeType::Increment ( ) { // Precondition: data members have been assigned values // Postcondition: time is advanced by 1 second with 23:59:59 wrapping // around to 0:0:0 secs = (secs+1)%60; if ( secs == 0) mins = (mins + 1) %60; if (mins == 0) hrs = (hrs + 1) % 24; }; // all class members are accessed without selection operator Notes: All class members, including private members, are accessible from the class implementation All members are accessed without the selection operator A. Berrached@UHD Intro to structs & classes

Implementation--LessThan bool TimeType::LessThan (TimeType otherTime ) cont { // Precondition: data members have been assigned values for both // this time and otherTime // Postcondition: return True if this time is earlier than otherTime; False //otherwise }; A. Berrached@UHD Intro to structs & classes

Class Constructors a class constructor is a member function whose purpose is to initialize the private data members of a class object a class constructor is automatically invoked when a class object is instantiated (i.e. declared). You define a class constructor the same way you define any other member function, except: the name of a constructor is always the name of its class there is no return type for a constructor. a class may have several constructors with different parameter lists. A constructor with no parameters is the default constructor. Constructors are never called explicitly. They are implicitly invoked. A. Berrached@UHD Intro to structs & classes

Specification of TimeType Class Constructors class TimeType // timetype.h { public : // 7 function members void Set ( int hours , int minutes , int seconds ) ; void Increment ( ) ; void Write ( ) const ; bool Equal ( TimeType otherTime ) const ; bool LessThan ( TimeType otherTime ) const ; TimeType ( int initHrs , int initMins , int initSecs ) ; // constructor TimeType ( ) ; // default constructor private : // 3 data members int hrs ; int mins ; int secs ; } ; A. Berrached@UHD Intro to structs & classes

Implementation of TimeType Default Constructor TimeType :: TimeType ( ) // Default Constructor // Postcondition: // hrs == 0 && mins == 0 && secs == 0 { hrs = 0 ; mins = 0 ; secs = 0 ; } A. Berrached@UHD Intro to structs & classes

Implementation of Another TimeType Class Constructor TimeType :: TimeType ( /* in */ int initHrs, /* in */ int initMins, /* in */ int initSecs ) // Constructor // Precondition: 0 <= initHrs <= 23 && 0 <= initMins <= 59 // 0 <= initSecs <= 59 // Postcondition: // hrs == initHrs && mins == initMins && secs == initSecs { hrs = initHrs ; mins = initMins ; secs = initSecs ; } A. Berrached@UHD Intro to structs & classes

Automatic invocation of constructors occurs TimeType departureTime ; // default constructor invoked TimeType movieTime (19, 30, 0 ) ; // parameterized constructor departureTime movieTime Set Set Private data: hrs mins secs Increment Private data: hrs mins secs Increment 19 30 Write Write LessThan LessThan Equal Equal A. Berrached@UHD Intro to structs & classes

What if no default constructor is defined ? TimeType departureTime ; // no default constructor defined TimeType movieTime (19, 30, 0 ) ; // error if no parameterized constructor Private data: hrs mins secs Set Increment Write LessThan Equal ? departureTime A. Berrached@UHD Intro to structs & classes

Class Destructor--Preview Invoked automatically when a class object is destroyed, example When control leave the block in which a local object is declared Named the same as the its class name, except that it is prefixed with a tilde character ~SomeClass() Only one destructor per class Generally used to de-allocate space allocated when class object was instantiated. A. Berrached@UHD Intro to structs & classes

Specification of TimeType Class Constructors class TimeType // timetype.h { public : // 7 function members void Set ( int hours , int minutes , int seconds ) ; void Increment ( ) ; void Write ( ) const ; bool Equal ( TimeType otherTime ) const ; bool LessThan ( TimeType otherTime ) const ; TimeType ( int initHrs , int initMins , int initSecs ) ; // constructor TimeType ( ) ; // default constructor ~TimeType (); // class destructor private : // 3 data members int hrs ; int mins ; int secs ; } ; A. Berrached@UHD Intro to structs & classes