|
Guillaume Caumon,
Fev 2000, revised Jan 2001 and Jan 2005.
This document is designed for 2nd year students of
the Nancy School of Geology, who have a good knowledge and practice of C.
I wrote this based on Thierry Valentin's course (1998), on my own experience of C++ and on the works cited below.
References
- C++
Annotations, by Frank B. Brokken. This on-line
book is very comprehensive, richly illustrated with concrete
examples. You can get a pdf version
- The C++ programming Language, Bjarne Stroustrup, Addison Wesley.
The reference book on C++, by its creator.
- Design patterns, Eich Gamma, Richard Helm, Ralph Johnson, John
Vlissides, Addison Wesley. Presents a pannel of patterns for oriented-object
programming, solving most of the traditional design problems.
- Effective C++, More effective C++ and effective STL, E. Meyers, Addisson Wesley. Containts many hints to help you achieve high-quality C++.
(Short) History of C++
C++ was first developped by AT&T Bell labs by Bjarne Stroustrup.
It can be seen as new set of functionalities created to extend C (hence
the "++").
The main points of C++ are :
- Creation and use of new types is easier than in C.
- C++ supports all features of object-oriented programming:
- A mechanism (inheritance) allows code reuse.
- Abstract concepts can be defined
- The behavior of a parent can be redefined by a child through virtual functions
- Memory management and I/O operations are more convenient than in C
- A stricter type checking than in C allows error detections
at compile-time (it is always better if you detect an error while compiling
than if your client or co-worker finds a bug while running the program...)
- Generic programming is supported by template functions/classes, meaning that a piece of C++ code can be parameterized by another piece of code.
C++ had been developped for about 4 years by Bjarne Stroustrup when it
became clear that a normalisation was necessary. As a consequence, the ANSI
comitee was created in 1989. Nowadays, the ANSI C++ comitee has more or less
finished defining the standard for C++. However, very few compilers
fully comply with this standard, which requires some care for developing
portable applications (across windows, linux, unix, mac, beos).
A recent evolution of C++ is the addition of the Standard Template Library,
which defines useful types such as string, vector, list, plus a
variety of algorithms.
This is a class on C++ and object-oriented programming, not on STL, so I will
not spend too much time describing what you can and cannot do with it.
Why Object-Oriented Programming (OOP) ?
The main principle of OOP is to allow a clear separation of tasks in a
program. This separation is mandatory for any large project involving several
people and bound to evolution.
In a company, all the employees have one ore several tasks to do, and links
(hierarchy, delegation, projects...) between the employees are defined to achive
the goals of the company. Similarly, a program can be separated into
components communicating with each other.
|