Chapter 13: Pointers, Classes, Virtual Functions and Abstract Classes

In chapter 13 we will learn about:
  • The pointer data type and pointer variables
  • The address of operator and the dereferencing operator
  • The new and delete operators
  • Pointer arithmetic and dynamic arrays
  • Shallow and deep copies of data
  • The peculiarities of classes with pointer member variables
  • Virtual functions
To get some experience with pointers I would like you to complete programming exercise 2 on page 793 which asks you to redo programming exercise number 6 from chapter 9 using dynamic arrays. This assignment is due in class two weeks from today, Tuesday, March 24, 2009.

Here is the data file for this assignment.

Inheritance and Composition: Disambiguation

In chapter 12, we learned about Inheritance and Composition. To further clarify the differences between Inheritance and Composition, I would like you to read the following articles: Object Composition vs. Inheritance by Paul John Rajlich, Research Programmer at The National Center for Supercomputing Applications; Inheritance versus Composition by Eric Florenzano, and The Inheritance versus Composition Duel by Abhijit Nadgouda.

After reading the above articles, please research the following questions on Inheritance versus Composition in class today and submit your answers by Tuesday, March 10, 2009.

Next week we will move forward with two new programming assignments: One related to Inheritance and Composition, and one related to Pointers.

Chapter 12: Inheritance and Composition

"Is - A" relationships and "Has - A" relationships... we all know relationships are complicated, so it should come as no surprise that Inheritance and Composition can seem a bit ambiguous at times.

Chapter 12 sheds some light on Inheritance and Composition, but quite frankly does a much better job at explaining Inheritance than it does Composition. This appears to be a common problem according to some further explanation by fellow programmers, Eric Florenzano, Abhijit Nadgouda, and Paul Rajlich.

This week we will explore the differences further by examining the above articles and completing a worksheet focusing on composition (See the Chapter 13 post for more information and a link to the worksheet).

Chapter 11: Classes and Data Abstraction

Chapter eleven deals with creating and implementing classes. Today in class we will learn about private, protected, and public members of a class; explore how classes are implemented; examine constructors and destructors; and learn how classes are used to implement abstract data types and about information hiding.


In Programming Assignment number 2 you will design and implement a class that gives the day of the week. The program requirements are listed on page 655 and 656. Follow the instructions given in the book to create the dayType class described in the exercise. This assignment is due in class next Tuesday, February 3rd.

Chapter 10: Records (structs)

In chapter 10 we examine structs, including performing operations on members of a struct, manipulating data using a struct, the relationship between a struct and functions, using arrays in a struct, and how to create an array of struct items.

Exercise 3 of chapter 10 reinforces our discussion and will give you an opportunity to use what we have just learned. I have modified the completed source code for Exercise 3 of Chapter 10 to allow you complete the assignment by completing the code snippet for the showMenu() function.

Open the modified source code for Exercise 3 (here's the data file, oops, sorry about that) and complete the showMenu() function as described in the comments within the showMenu() function. This is due in class next Tuesday, January 27.

Chapter 9 C-Strings and Two Dimensional Arrays

As requested here are a couple of programs dealing with C-strings and Two Dimensional Arrays.

Exercise 6 and excercise 9 from chapter 9 are mostly complete. Your assignment is to complete each of the programs and understand how the c-string (in exercise 6) and the two dimensional array (in exercise 9) are accessed and processed in each of the programs.

Chapter 9 exercises 6 & 9 are due in class next Tuesday, January 27.

Chapter 9: Arrays and Strings

Tonight we will be reviewing Chapter 9 which covers Arrays and Strings.

Your assignments include End of Chapter exercises 2, 4, 5 & 8 (pages 535 - 536), and Programming Exercise 4 (page 539).

Programming Exercise 4 asks you to write a program that reads a file consisting of students' test scores in the range 0 - 200. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99,100-124, 125-149,150-174, and 175-200.

Output the score ranges and the number of students. (Run your program with the following input data: 76 89 150 135 200 76 12 100 150 28 178 189 167 200 175 150 87 99 129 149 176 200 87 35 157 189)

For your convenience, here is a link to the input file for Programming Exercise 4.