- Room A309K - College Building
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.
On successful completion of this course, students should be able to:
- read and modify substantial well-written C++ programs.
- create classes and small programs in C++ that are correct,
robust and capable of being understood, reused and modified by
- make use of various object-oriented features, including
inheritance, multiple inheritance and genericity, to enhance
the above qualities.
Course Outline - Sessions
- 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]
- Classes in C++
[Savitch 1, 6.2, 7.1; Stroustrup 2.5.3-4, 2.6, 10.1-6;
(Also, [Stroustrup 18.104.22.168] for how to turn assertions
- 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]
- 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]
- 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]
- 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
- Multiple inheritance
[Stroustrup 15.2] Only Stroustrup for this; the
others have nothing.
- Memory management: static, stack, dynamic.
Construction and destruction of objects
[Savitch 10.3; Stroustrup 10.4; Horstmann 13.2]
- 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)
- Resource management and exceptions
[Savitch 18; Stroustrup 14]
Copies of lecture slides and weekly lab exercises (in addition to
The slides, lab-work and past exams have been kindly provided by
Dr. Ross Paterson.
- Walter Savitch,
Absolute C++, Addison-Wesley Longman,
Reading, Mass, 2002.
(Obviously you can get newer editions of these books.)
Stroustrup, The C++ Programming Language, 3rd
edition, Addison-Wesley Longman, Reading, Mass, 1997.
- Cay Horstmann,
Computing Concepts with C++ Essentials,2nd edition,
Meyer, Object-Oriented Software Construction,
2nd edition, Prentice Hall, 1997.
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.
When learning C++, it's helpful to remember that it's 4 languages in
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.
- A better C, i.e., a procedural language but more type-safe than C.
That's why, for example, the Linux kernel is compiled with a C++
compiler, although it's plain C code; C++'s stronger type-safety helps
catch more bugs at compile time.
- A language for data abstraction
- A language for object-orientation
- A language for generic programming (using templates, as in the STL
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...
- A list of available C++ libraries known as the C++ libraries
- Boost.org: A repository for
libraries meant to work well with the C++ standard library.
- High-performance numerical libraries provide excellent tests
for interesting new programming techniques:
ROOT from CERN.
This page does not appear to be using a
stylesheet. It will be much improved if you use a recent browser that
supports cascading style sheets.