Course pages 2016–17
Programming in C and C++
Principal lecturer: Dr Neel Krishnaswami
Taken by: Part IB
Past exam questions
No. of lectures: 10
Suggested hours of supervisions: 3
Prerequisite courses: None, though Operating Systems would be helpful.
Aims
The aims of this course are to provide a solid introduction to programming in C and C++ and to provide an overview of the principles and constraints that affect the way in which the C and C++ programming languages have been designed and are used.
Lectures
- Introduction to the C language. Background and goals of C. Types and variables. Expressions and statements. Functions. Multiple compilation units. [1 lecture]
- Further C concepts. Preprocessor. Pointers and pointer arithmetic. Data structures. Dynamic memory management. Examples. [2 lectures]
- Introduction to C++. Goals of C++. Differences between C and C++. References versus pointers. Overloading functions. [1 lecture]
- Objects in C++. Classes and structs. Operator overloading. Virtual functions. Multiple inheritance. Virtual base classes. Examples. [2 lectures]
- Further C++ concepts. Exceptions. Templates, meta-programming and the STL. Examples. [2 lectures]
- Linkers and loaders. Executable sections. Debug symbols. Inspecting program state. [1 lecture]
- C semantics. Undefined vs implementation-defined behaviour. Common optimisation problems. Buffer and integer overflows. Examples. [1 lecture]
Objectives
At the end of the course students should
- be able to read and write C and C++ programs;
- understand the interaction between C and C++ programs and the host operating system;
- be familiar with the structure of C and C++ program execution in machine memory;
- understand the object-oriented paradigm presented by C++;
- be able to make effective use of templates and meta-programming techniques as used in the STL;
- understand the potential dangers of writing programs in C and C++.
Recommended reading
* Eckel, B. (2000). Thinking in C++, Vol. 1: Introduction to Standard C++. Prentice Hall (2nd ed.). Also available at
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Kernighan, B.W. & Ritchie, D.M. (1988). The C programming language. Prentice Hall (2nd ed.).
Stroustrup, B. (2008). Programming -- principles and practice using C++. Addison-Wesley.
Stroustrup, B. (1994). The design and evolution of C++. Addison-Wesley.
Lippman, S.B. (1996). Inside the C++ object model. Addison-Wesley.