C++ notes
Roger Mitton's preface:
In the first year that we ran the C++ course, one of the first-year
part-time students, Stephen Connolly, put all his notes on the web for
the benefit of his fellow students. He has now kindly provided them to me. His notes provide the basis for what is presented here, though
I have made corrections, additions and changes to reflect developments of the course.
Full-time students do the course at
double speed odd-numbered "weeks" on Mondays, even-numbered "weeks" on
Wednesdays.
As well as the notes for the C++ course, there is some recommended pre-course reading. The first three items are the introductory material
on which applicants take a test at the admissions interview. Students are
assumed to be familiar with this by the start of the MSc/PGDip course. The fourth is an extra item of optional pre-course reading on C++. The other two are for students whose maths is rusty.
For other C++ course materials (assignments, lab worksheets etc), go to the
Module outlines.
Stephen Connolly's preface:
Since there aren't any handouts for the course and we're all likely
to miss one or two lectures, here's a stab at providing absentees with
what they've missed. No responsibility is accepted for eventual errors
and omissions (though I've tried to be as accurate as I can).
Most of the sample code has been tested for accuracy under CCN or g++.
Clicking on some links will bring the code up in a separate browser window
so you can copy and paste it into a text editor and tweak it yourself.
If nothing happens, it may be that the window with the code in it is behind
the current browser window. I can't fix this bug according to the books
it ought to work but it looks like the browsers I've tested it with don't
support JavaScript's Focus() method properly.
Pre-course reading
-
Pre-course introduction to C++,
1 (1, 2 and 3 are required pre-interview reading)
-
Simple input/output with integers, outputting words and ends of lines, assignment and initialization
-
Pre-course introduction to C++,
2
-
Arithmetic expressions, identifiers and comments, string variables, conditionals, two-way branches, ASCII
-
Pre-course introduction to C++,
3
-
Loops, booleans, #include, using namespace, main
-
Pre-course introduction to C++,
4 (optional pre-course reading)
-
Functions, procedures, return types, parameter passing
-
A lesson on octal, hex, and binary
-
A refresher on basic arithmetic
C++ course notes
-
Week
1
-
Program structure, #includes, variables, assignments,
input and output, expressions, operator precedence and associativity, type conversion, strings
-
Week
2
-
Use of objects, member functions. Conditionals, booleans, order of evaluation of operands, lazy evaluation, conditional operator, the switch statement
-
Week
3
-
Loops - while, for, and do, Handling filestreams for
input and output, stringstreams
-
Week
4
-
Procedures and functions, parameter passing and return values, error handling and assert, nested loops
-
Week
5
-
More on functions, prototypes, value and reference parameters, side-effects, scope and lifetimes (statics, globals and extern), the system stack
-
Week
6
-
Vectors, strings as vectors of char
-
Week
7
-
Introduction to classes: a simple Date class
-
Week
8
-
More classes - Stack and Queue, static data members, representation of integers, static_cast
-
Week
9
-
Dynamic data structures - pointers and linked lists, heap storage
-
Week
10
-
More on linked lists: inserting and deleting nodes. Stack and Queue as singly-linked lists
-
Week
11
-
Implementing a Deque class with singly- and doubly-linked lists; a first look at binary trees
-
Week
12
- A sample halfway test
-
Week 13
- Two-dimensional vectors, typedef, arrays and pointers, C-strings, character-level I/O, precision of doubles
-
Week 14
- const data members, overloading the output operator with a non-member function, a Safevec class
-
Week 15
-
Recursion, and binary trees again
-
Week 16
-
More recursion: building a binary search tree, the Towers of Hanoi, recursion in language
-
Week 17
-
Objects containing pointers: copy constructor, overloaded assignment operator, destructor
-
Week 18
-
Inheritance and polymorphism
-
Week 19
-
Exception handling
-
Week 20
-
Function overload resolution
-
Week 21
-
Templates, header files and preprocessor commands, the STL
-
Week 22
-
Sample end-of-term tests