C++ is an object-oriented version of C, and was finally standardised in 1997. Compiler makers have tracked the developing standards, so that recent C++ compilers should conform pretty closely to the standard even if they formally pre-date it.
Object-orientation is the notion that functions are
attached to data, rather than simply operating on
them. For example, if a C program were to declare a data
type Array
, and initialise a variable of that
type with Array a;
then one can imagine a
function to return the determinant of the array, declared
as float determinant (Array a);
. In C++, the
`function' to obtain the determinant could be declared as
part of the data type, and obtained via the
expression a.determinant()
. There are two
main points to this. Firstly, the so-called `member
function' determinant
can have privileged
access to the internal representation of the data type
Array
, so that other parts of the program
need not, and may not, manipulate that representation,
erroneously or otherwise. Secondly, and consequently, the
representation and matching member functions can be
changed with the guarantee that the rest of the
program will be unable to tell the difference. This is
characterised in the remark that new programs have always
been able to use old code (in libraries), but
object-oriented approaches mean that old programs can use
new code (when an implementation changes, while the
interface remains the same).
Of course, both of these points are to some extent true of traditional programming languages -- indeed I'd doubt that there's anything you can do in C++ which you couldn't do with some ingenuity in C -- but the point is that they are much easier, and much more natural, in C++.
It may be clear at this point that C++ is not a beginner's language. The result of grafting a high-level abstraction onto portable assembler is a language with far more syntax than is healthy. Do not feel you need to learn C before C++-- they are closely enough related that the differences can be confusing. My feeling, however, is that you should consider learning Javafirst if you have the time: there is relatively little that needs to be unlearned going from Java to C++, and Java's simplicity makes it easier to come to grips with object-orientation, without drowning in a sea of punctuation.
The excellent C++ FAQ includes book recommendations. The canonical book for C++, with the same status K&R has for C, is The C++ Programming Language [stroustrup], by the language's author. However, I find Stroustrup's book rather irritating: it's rather badly organised, and the index is dreadful.
Note, by the way, that the C++ compiler on Suns is named
CC
, on Alphas named cxx
, and on
Linux named both c++
and
g++
.