Classes and Abstraction in Object-Oriented Design

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/75

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

76 Terms

1
New cards

Object Oriented Design (OOD)

A problem solving methodology

2
New cards

Objects

Components of a solution

3
New cards

Class

A collection of a fixed number of components

4
New cards

Member

Component of a class

5
New cards

Class Definition

Defines a data type; no memory is allocated

6
New cards

Class member

Can be a variable or a function

7
New cards

Variable member of a class

It's declared like any variable; you cannot initialize a variable when you declare it

8
New cards

Function member of a class

Function prototype is listed; function members can (directly) access any member of the class

9
New cards

Private member

Member cannot be accessed outside of class

10
New cards

Public member

Member that can be accessed outside of class

11
New cards

Protected member

Member that can be accessed by derived classes

12
New cards

Unified Modeling Language

Used to graphically describe a class and its members

<p>Used to graphically describe a class and its members</p>
13
New cards

Class variable

Called a class object or class instance

14
New cards

Member access operator

The dot (.) is used to access class members

15
New cards

Automatic object

Created when the declaration is reached and destroyed when the surrounding block is exited

16
New cards

Static object

Created when the declaration is reached and destroyed when the program terminates

17
New cards

Passing by value

Contents of data members of the actual parameter are copied into the corresponding data members of the formal parameter

18
New cards

Passing by reference

The formal parameter receives only the address of the actual parameter

19
New cards

Const in formal parameter

Used to prevent changes to the actual parameter when passing by reference

20
New cards

Accessor Function

Member Function that only accesses the value(s) of member variable(s)

21
New cards

Mutator Function

Member Function that modifies the value(s) of member variable(s)

22
New cards

Constant Function

Member Function that cannot modify member variables

23
New cards

Instance Variables

Each object has its own copy of the member variables (hr, min, sec)

24
New cards

Scope resolution operator

Used to access identifiers local to the class

25
New cards

Client of a class

A program that uses/manipulates objects of a class

26
New cards

Public member

Member can be accessed outside of class

27
New cards

Protected member

Member can be accessed by derived classes

28
New cards

Member access operator

The dot (.) is used to access members of a class

29
New cards

Constant Function

Member Function that cannot modify member variables; use const in function heading

30
New cards

Order of Members

C++ has no fixed order in which to declare private and public functions.

31
New cards

Default Member Access

By default, all members of a class are private.

32
New cards

Public Member Access

Use the member access specifier public to make a member available for public access.

33
New cards

Constructors

Use constructors to guarantee that member variables of a class are initialized.

34
New cards

Types of Constructors

Two Types of Constructors: a) Default Constructor (no parameters), b) Parameterized Constructor (with parameters).

35
New cards

Constructor Naming

Name of Constructor = Name of the Class.

36
New cards

Constructor Type

A constructor has no type.

37
New cards

Multiple Constructors

A class can have more than one constructor; each must have a different formal parameter list.

38
New cards

Constructor Execution

Constructors execute automatically when a class object enters its scope.

39
New cards

Constructor Invocation

A constructor is automatically executed when a class variable is declared.

40
New cards

Specific Constructor Invocation

Because a class may have more than one constructor, you can invoke a specific constructor.

41
New cards

Default Constructor Invocation Syntax

To invoke the default constructor: className classObjectName.

42
New cards

Parameterized Constructor Invocation Syntax

Syntax: className classObjectName (argument1, argument2, ...).

43
New cards

Argument Matching

Number and type of arguments should match the formal parameters of one of the constructors.

44
New cards

Type Conversion

Otherwise, C++ uses type conversion and looks for the best match; any ambiguity causes a compile-time error.

45
New cards

Default Parameters in Constructors

Constructor can have default parameters; rules for declaring formal parameters are the same as for declaring default parameters in a function.

46
New cards

Default Constructor Definition

A constructor with no parameters or with all default parameters.

47
New cards

Default Constructor Provision

If a class has no constructor(s), C++ provides the default constructor; however, the object declared is still uninitialized.

48
New cards

Absence of Default Constructor

If a class includes constructors(s) with parameter(s), but not the default constructor, C++ does not provide the default constructor.

49
New cards

Array of Class Objects

If you declare an array of class objects, the class should have the default constructor.

50
New cards

Destructor

Functions without any type.

51
New cards

Destructor Naming

Name of a destructor is the character "~" followed by the class name (ex: ~clockType).

52
New cards

Single Destructor

A class can only have one destructor; the destructor has no parameters.

53
New cards

Destructor Execution

Destructor automatically executes when class object goes out of scope.

54
New cards

Abstraction

Separating design details from usage; separating the logical properties from the implementation details.

55
New cards

Abstract Data Type (ADT)

Data type that separates the logical properties from the implementation details.

56
New cards

Struct vs Class

By default, members of a struct are public; private specifier can be used in a struct to make a member private.

57
New cards

Members of Class

By default, members of a class are private.

58
New cards

Capabilities of Classes and Structs

Classes and structs have the same capabilities.

59
New cards

Expanded Struct Definition

In C++, the definition of a struct was expanded to include member functions, constructors, and destructors.

60
New cards

Using Struct

If all member variables of a class are public and there are no member functions, use a struct.

61
New cards

Information Hiding

Hiding the details of the operations on the data.

62
New cards

Interface

Contains the specification details.

63
New cards

Implementation File

Contains the implementation details (file extension is .cpp).

64
New cards

Function Prototypes in Header

In header file, include function prototypes and comments that briefly describe the functions.

65
New cards

Precondition

A statement specifying the condition(s) that must be true before the function is called.

66
New cards

Postcondition

A statement specifying what is true after the function call is completed.

67
New cards

Static Members

Use the keyword static to declare a function or variable of a class static.

68
New cards

Accessing Static Members

A public static function or member of a class can be accessed using the class name and the scope resolution operator.

69
New cards

Static Member Variables

Static member variables of a class exist even if no object of that class type exists.

70
New cards

Non-static Member Variables

Multiple objects of a class each have their own copy of non-static member variables.

71
New cards

Shared Static Members

All objects of a class share any static member of the class.

72
New cards

Class Summary

Class: collection of a fixed number of components.

73
New cards

Class Members

Members: components of a class; accessed by name; 3 Categories: public, private, protected.

74
New cards

Class Variables

Class variables are called class objects or simply objects.

75
New cards

Built-in Operations on Classes

The only built-in operations on classes are assignment and member selection.

76
New cards

Instance Variables

Instance variables: non-static data members.