You can join the Facebook group for this module here.
Lab exercise on C++ templates for weeks 9-11
The demonstrator for this module is Asiri Rathnayake. You can ask him for help in the lab.
Lab times are Monday afternoon.
Here are some guidelines on creating good multiple-choice questions.
You need to register on the Peerwise server.
- The course ID for this module is 8361.
- Your "identifier" on Peerwise is the same as your Bham student ID number.
- You can choose any username and password when registering.
- Please tag your questions with appropriate topics, so that others can find them more easily.
The last Peerwise homework deadline will be in week 9.
Lecture notes and code
- List of topics covered so far in the lectures
- Code for week 1/2: Evaluating expressions using a stack. This example introduces C pointers and pointer arithmetic.
- Code for week 2/3: Doubly-linked lists in C. This example introduces struct, malloc, and free. Doubly-linked lists are used a lot in operating system kernels.
- Code for week 3: More on struct and union
- Code for week 4: More pointers: function pointers, void pointers, "dangling" pointers
An introduction to parse trees in C/C++:
parse tree code in C and code in C++
- Intro to C++ slides, week 7
- Destructors in C++, week 8
An introduction to C++ templates, aimed at readers who know some functional programming.
Slides from the lectures
A note on how to write objects
and classes in C. (Yes, plain C, not C++.) We build everything by
hand, which shows how C++ arose from C.
Code for objects in C
There will be a class test in week in the lecture slot on 13 February. The test will be on C and counts for 10 % of the module mark.
C and C++ standards
- The C standard draft from 2011. Not an easy read, but when it comes to questions about what some piece of C code means, this is the authority.
- C syntax, formally defined as a grammar in about 400 lines of clickable HTML
- C++11 standard for C++, draft from 2012.
Brian W Kernighan and Dennis M Ritchie. The C programming language. (2nd Edition) Prentice-Hall, 1988. Available on Kindle
Bjarne Stroustrup. The C++ Programming Language. (4th Edition) Addison Wesley, 2012. Available on Kindle