CPSC 427a: Object-Oriented ProgrammingHandout #6
Professor M. J. Fischer   October 12, 2010


Study Guide to Exam 1

For the exam, you are responsible for the contents of lectures 1–11, the class demos, the concepts used in problem sets 1–3, and the corresponding sections of the textbook. In greater detail, you are responsible for the following chapters and sections of the textbook:

In addition, Chapter 15 presents some detailed code examples that use polymorphism and virtual functions. While we haven’t gone through the examples in class, you should read this chapter and make sure you understand how these concepts work in the examples presented there.

Below is an index to the lecture notes. It lists all of the sections, subsections, and slide titles from lectures 1–11.

1 About This Course [lecture 01]

   Where to find information

   Course mechanics

   Topics to be Covered

   Course goals - practical

   Course goals - conceptual

2 Kinds of Programming [lecture 01]

   Two views of programming

   Problem solving

   Software Construction

   Programming in the large

3 C++ Programming Standards [lecture 01]

   Three commandments for this course

   Can is not the same as should!

4 C++ Overview [lecture 02]

   General properties of C++

4.1 Comparison of C and C++

   C++ Extends C

   Some Extensions in C++


5 Example [lecture 02]

5.1 Insertion sort

   Generic Insertion Sort

5.2 C version

   C version

   C++ version

6 Header file [lecture 03]


   class DataPack

   Class elements

   Inline functions






7 Implementation File [lecture 03]


   File I/O

8 Main Program [lecture 03]


9 Building Your Code [lecture 03]

   Manual compiling and linking


   Integrated Development Environment (e.g., Eclipse)

   Integrated Development Environment (e.g., Eclipse)

   Integrated Development Environment (e.g., Eclipse)

10 Remarks on Laboratory Work [lecture 04]

   Toolset to use for course work

   Working remotely

   1. Replicate the Zoo environment on your own machine

   2. Remote login to the Zoo

   3. Set up a virtual Zoo desktop on your machine

   Homework submission

11 Review and Readings [lecture 04]

   A brief course review to date

   How to use the textbook

12 More on C++ I/O [lecture 04]

   Opening and closing streams

   Reading data

   Writing data


   End of file and error handling

13 IO Demos [lecture 05]

   Handling data errors and end of file

   How to write a test program

14 Introduction to Classes [lecture 05]

   Classes, visibility, functions, inline

   Stack example

15 Functions and Methods [lecture 05]

15.1 Parameters

   Call by value

   Call by pointer

   Call by reference

   I/O uses reference parameters

15.2 Choosing Parameter Types

   How should one choose the parameter type?

   Sending data to a function: call by value

   Sending data to a function: call by reference or pointer

16 Functions and Methods [lecture 06]

16.1 Choosing Parameter Types

   How should one choose the parameter type?

   Sending data to a function: call by value

   Sending data to a function: call by reference or pointer

   Receiving data from a function

16.2 The Implicit Argument

   The implicit argument


17 Simple Variables [lecture 06]

   L-values and R-values

   Simple variable declaration

   Simple assignment

   Automatic dereferencing

18 Pointers [lecture 06]

   Pointer values

   Pointer creation

   Pointer variables

   Pointer assignment

   Following a pointer

   Pointer example

   Pointer declaration syntax

19 References [lecture 06]

   Reference types

   Reference declarators

   Use of named references

   Reference parameters

   Reference return values

   Custom subscripting

   Constant references

   Comparison of reference and pointer

20 Remarks on Problem Sets [lecture 07]

20.1 Problem Set 1

20.2 Problem Set 2

   Pseudorandom number generators

   Random numbers in C++

   rand() and srand()

   Generating uniform distribution over a discrete interval

   Generating random doubles

   Alternate method for generating uniform distribution over a discrete interval

   Generating exponential distribution

21 BarGraph Demo [lecture 07]

   Bar Graph Demo

21.1 graph.hpp

22 BarGraph Demo [lecture 08]

   Bar Graph Demo

22.1 graph.hpp

   Notes: graph.hpp

22.2 graph.cpp

   Notes: graph.cpp

22.3 row.hpp

   Notes: row.hpp

22.4 row.cpp

   Notes: row.cpp

22.5 rowNest.hpp

   Nested classes: rowNest.hpp

23 Storage Managemet [lecture 08]

   Storage classes

   Assignment and copying

   Static data members

   Static function members

   Five common kinds of failures

24 Bells and Whistles [lecture 08]

   Optional parameters


   const implicit argument

   Operator extensions

25 Remarks on Problem Set 2 [lecture 09]

   Coding conventions for this course

   Coding conventions (cont.)

   Error checking and error handling

   Design choices

   PS2 issues

26 Classes [lecture 09]

   What is a class?

   Class relationships

27 Derivation [lecture 09]

   What is derivation?


   Some uses of derivation

28 Construction, Initialization, and Destruction [lecture 09]

   Structure of an object

   Referencing a composed object

   Referencing a base object

   Initializing an object

   Construction rules

   Destruction rules

   Constructor ctors

   Initialization ctors

   Initialization not same as assignment

   Copy constructors

29 Name Visibility [lecture 10]

   Private derivation (default)

   Private derivation example

   Public derivation

   Public derivation example

   The protected keyword

   Protected derivation

   Privacy summary

30 Polymorphic Derivation [lecture 10]

   Polymorphism and Type Hierarchies

   Polymorphic pointers

   Virtual functions

   Unions and type tags

   Virtual destructors

   Uses of polymorphism

   Multiple representations

   Heterogeneous containers

   Run-time variability

   Pure virtual functions

   Abstract classes

31 PS2 Craps Game Revisited [lecture 10]

   Extending existing code

   Summary of extensions

   1. Polymorphic dice

   2. Command line interface

   3. Command line parser

   4. Naming convention with underscores

   4. Naming convention without underscores

   5. Print functions

   Other changes

32 Name Visibility Revisited [lecture 11]

   Surprising example 1

   Surprising example 2: contrast the following

   Surprising example 3

   Names, Members, and Contexts

   Declaration and reference contexts

   Declaration context example

   Reference context example

   Inside and outside class references


   Inherited names

   Inheritance example

   Inaccessible base class

33 Interacting Classes and UML [lecture 11]

   What is a Class: Syntax

   Class Relationships

   Class Relationship Between Two Classes

   Class B appears in Definition of Class A

   B as Data Members in A

   B as Data Members in A

   Creation and Deletion

   Example: BarGraph Class Interaction

   Association Relationship