|
|
|
|
|
|
|
cludes preconditions and postconditions in the interface documentation, control abstraction, encapsulation, and physical versus conceptual hiding of an implementation. Chapter 8 expands the discussion to include reference parameters, scope and lifetime, stubs and drivers, and more on interface design, including side effects. |
|
|
|
|
|
|
|
|
Chapter 9 covers the remaining ice cream and cake control structures in C++ (Switch, Do-While, and For), along with the Break and Continue statements. We describe the practice of placing a loop invariant as a comment within the loop, and program examples throughout the remainder of the book contain loop invariants as part of the internal documentation. Chapter 9 forms a natural ending point for the first quarter of a two-quarter introductory course sequence. |
|
|
|
|
|
|
|
|
Chapter 10 begins a transition between the control structures orientation of the first half of the book and the abstract data type orientation of the second half. We examine the built-in simple data types in terms of the set of values that variables or constants of that type can contain and the allowable operations on values of that type. We introduce more C++ operators, and discuss the problems of floating point representation and precision at length. User-defined simple types, user-written header files, and type coercion are among the other topics covered in this chapter. |
|
|
|
|
|
|
|
|
We introduce the array data type in Chapter 11. Arrays can be a big conceptual hurdle for students: a variable to access another variable? Three case studies and numerous small examples assist students in making the jump successfully. Three typical types of array processing (subarray processing, parallel arrays, and indices with semantic content) and patterns of array access (randomly, sequentially, and as a single object) are covered. |
|
|
|
|
|
|
|
|
Chapter 12 gives students more experience with array processing and introduces the list, informally, as an abstract data type. Algorithms that are commonly applied to lists are developed and coded as general-purpose C++ functions. We describe strings and string-handling routines. A case study applies several of the functions written in the first part of the chapter to strings to demonstrate the general applicability of the functions. We use Big O notation to compare the various searching and sorting algorithms developed in the chapter. |
|
|
|
|
|
|
|
|
Multidimensional arrays are introduced in Chapter 13, and records (structs) are presented in Chapter 14 along with a discussion on how to choose an appropriate data structure. In this discussion, we introduce the concept of data abstraction as a prelude to the material in Chapter 15. |
|
|
|
|
|
|
|
|
In Chapter 15, we give a precise definition to the notion of an ADT, emphasizing the separation of specification from implementation. The C++ class mechanism is introduced as a programming language representation of an ADT. The concepts of encapsulation, information hiding, and public and private class members are stressed. We describe separate compilation of program files, and students learn the technique of placing a class's declaration and implementation into two separate files: the specification (.h) file and the implementation file. |
|
|
|
|
|