ICS 65 Fall 2012
Code Examples from Fall 2010


Code examples

Since this course is somewhat of a rebuild from its previous incarnation (Fall 2010), I was asked by a couple of students to preserve the code examples from that previous version of the course. These are those code examples.

You will see some of these code examples show up verbatim later in the course; others will be replaced with new ones, or will be modified from what you see here.

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