ICS 65 Fall 2011
Code Examples


Code examples, from lecture and otherwise

Over the course of the quarter, I'll be providing commented code examples for you. These examples are mostly to give you clean and well-documented examples of some of the things we cover in lecture (and possibly a few things that we don't, time permitting), so that you can be free in lecture to avoid trying to take detailed notes when we're writing code together, instead concentrating on understanding the process and the bigger-picture concepts at work when we develop the examples.

Lecture Date Description
Tu 9/28 The square/cube example of separate compilation from lecture (including protection against multiple inclusion)
Th 9/30 A few odds and ends from the lecture that included default arguments, references, pass-by-reference parameters, and "constness"
Th 10/7 The Song example of writing a class in C++
Tu 10/12 The Blarg example of destructors, copy constructors, and overloaded assignment operators
Th 10/14
Tu 10/19
The "well-behaved" Queue example
Th 10/21 A variety of examples of using the C++ Standard Library
Tu 10/26
Th 10/28
The Person/Student example of inheritance (including polymorphism and virtual functions)
Th 10/28 The Shape/Circle example done badly (including a virtual function call in constructor)
Th 10/28
Tu 11/2
The Shape example done right (including the use of a "mutable" member variable and an explicit constructor)
Th 11/4 The Complex class, as an example of operator overloading
Tu 11/9 Writing template functions
Tu 11/16 A template version of our "well-behaved" Queue
Tu 11/16 The "polymorphic clone" technique
Th 11/18 The Person/StudentEmployee example of multiple inheritance, virtual inheritance, and the "diamond inheritance problem"
Tu 11/23 An implementation of Vector using dynamically-allocated arrays and exception safety techniques