Computer Laboratory

Course pages 2012–13

Programming in C and C++

Principal lecturer: Prof Alan Mycroft
Taken by: Part IB
Past exam questions
Information for supervisors (contact lecturer for access permission)

No. of lectures: 8
Suggested hours of supervisions: 2
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 and meta-programming. Java Native Interface (JNI). Examples. [2 lectures]

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.