Module Programming in C++
Title Syllabus
Authors Christos Kloukinas

Lecturer

Christos Kloukinas
Office
Room A205 - College Building

Aims

Assuming a basic understanding of object-oriented programming techniques and the Java language, this module will explore object-oriented programming techniques in greater depth.
The module will focus on practical applications, using the C++ language, which is widely used in industry.

Learning Objectives

On successful completion of this course, students should be able to:

Course Outline - Sessions

  1. Introduction to C++ for Java programmers.
    Parameter passing by value and reference
    [Savitch 4; Stroustrup 2.1-3 (except 2.3.3), 3.2-6 (except 3.5.1), 3.7.1, 5.5; Horstmann 5.7-8]
  2. Classes in C++
    [Savitch 1, 6.2, 7.1; Stroustrup 2.5.3-4, 2.6, 10.1-6; Horstmann 8]
    (Also, [Stroustrup 24.3.7.2] for how to turn assertions off)
  3. Operator overloading
    [Savitch 8.1; Stroustrup 7.4,11; Horstmann 13.4]
    More on I/O in C++
    [Savitch 8.3; Stroustrup 21; Horstmann 10.1]
  4. Genericity (or parametric polymorphism). C++ templates
    [Savitch 16.1-2; Stroustrup 13.2-3; Horstmann 13.5]
    Introducing the standard template library (STL)
    [Savitch 19.1; Stroustrup 16.2.3, 16.3; Horstmann 13.5]
  5. Pointers and arrays
    [Savitch 10.1; Stroustrup 5.1-3; Horstmann 9.7]
    Iterators in the STL
    [Savitch 17.3, 19.2; Stroustrup 19.1-2]
  6. Inheritance and dynamic binding in C++
    [Savitch 14, 15; Stroustrup 12; Horstmann 14]
    Genericity, pointers and inheritance
    [Savitch 16.3; Stroustrup 12]
    (For more on templates and subtyping: [Stroustrup 13.6.3])
  7. Multiple inheritance
    [Stroustrup 15.2] Only Stroustrup for this; the others have nothing.
  8. Memory management: static, stack, dynamic.
    Construction and destruction of objects
    [Savitch 10.3; Stroustrup 10.4; Horstmann 13.2]
  9. Memory management, continued.
    Implementing a container class.
    Program structure, separate compilation, header files
    [Savitch 11.1; Stroustrup 9]
    (Also [Stroustrup 13.7] for compiling templates)
  10. Resource management and exceptions
    [Savitch 18; Stroustrup 14]

Material Provided

Copies of lecture slides and weekly lab exercises (in addition to assignments).
The slides and lab-work are based on material initially produced by Dr. Ross Paterson.

Course Text

Background Reading

(Obviously you can get newer editions of these books.)

Concerning the books listed above, please note that the most "authoritative" one is Bjarne Stroustrup's book, since he's the author of the C++ language.

For example, if you look at Savitch's "Absolute C++" book, "Further reading" section, he too says that if you should buy a single book on C++, Stroustrup should be your choice. Savitch also refers the reader to other, more advanced, books at certain occasions.

The catch: you may find Stroustrup a bit more difficult to understand, depending on your programming experience (of course you may find the others a bit too easy/boring... ;-)

So, better go to the library and check them out - compare a chapter or two to see with which one you feel more comfortable with.

Various

When learning C++, it's helpful to remember that it's 4 languages in one:

It's also helpful to remember that, unlike Java, C++ was meant to be as close as possible to C and as fast as possible. The latter means that one has access to low-level mechanisms and that the language provides more than one ways of doing things. Programmers choose among the alternatives based on how abstract (or how fast) they want their code to be.

So, C++ can be used both for writing programs which follow all the principles of well structured object-oriented / generic-programming / data-abstraction programs and for writing programs which break almost all of the rules to get maximum speed.

C++'s complexity stems from these two points: its 4-in-1 nature and the fact that it gives you absolute control of the machine.

Some on-line books/documents/references

Becoming a Proficient C++ Programmer

In order to become a proficient C++ programmer you'll have to study other people's code, so that you can learn from their faults and their experience, in just the same way that an architect studies existing buildings. Here's a small list of libraries selected from Stroustrup's page, you can study or use in your programs.

Note that this is provided for information only - it would probably be too hard for you to study any of this right now, better leave this for after the end of the course...