ICS 65 Fall 2012
Code Examples


Code examples, from lecture and otherwise

Over the course of the quarter, I'll be providing commented code examples for you. You are not permitted to copy and paste any of this code into your own projects. 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.

Lecture Date(s) Description
Tu 10/9 Separate compilation using header and source files, including the prevention of multiple inclusion
Tu 10/9 Overloading functions, writing functions with default arguments, and understanding overload resolution rules
Tu 10/16 Various examples of creating, manipulating, and destroying statically- and dynamically-allocated arrays
Th 10/18 Declaring and using structs
Th 10/18 A brief exploration of struct layout and padding
Tu 10/23 A first look at C++ classes
Th 10/25 A "well-behaved" Vector class, including the Big Three
Th 11/1
Tu 11/6
Using the containers, generic algorithms, and iterators from the standard library
Th 11/8
Tu 11/13
Persons, Students, and inheritance and polymorphism in C++
Tu 11/13 Pure virtual functions and abstract base classes
Th 11/15 The Complex type, as an example of operator overloading
Tu 11/20 Writing and calling template functions
Tu 11/20 Writing and using template classes
Tu 11/20 Understanding pseudorandom number generation in the C++ standard library
N/A The "polymorphic clone" pattern
Th 11/29 Exceptions and exception safety
Tu 12/4 Writing a standard-library-compliant container class (including an iterator)
Th 12/6 Using private inheritance to implement a stack class that inherits (privately) from vector


Old code examples

As this quarter's offering is a new incarnation of this course, I was asked by a couple of students to preserve the code examples from the previous version of this course. Those examples, some of which you'll see again this quarter and others you won't, are available at the link below.