The C language was originally introduced
as a (Unix) systems programming language,
and is gradually being replaced by C++ for this purpose.
However, C++ lends itself to many other applications,
including mathematical programming and business applications.
Terminology
Among the additional keywords introduced in C++ (extending C) we have the keyword const (which may be used to define constants), the keyword inline (which may be used to define inline expanded functions, that for C have to be defined using macros), the keyword new (to dynamically create objects on the heap), the keyword delete (to destroy dynamically created objects) and, finally, the keywords private, public and protected (to indicate access restrictions for the instances of an object class). See slide cc-term.
The annotated reference manual (ARM) is not a book to be used to learn the language, but provides an excellent source of detailed technical explanations and the motivations underlying particular design decisions.
name -- denotes an object, a function, set of functions, enumerator, type, class member, template, a value or a label
object -- region of storage
Assignments in C++, it is important to note,
are written as var = expression with a single =
symbol.
This convention is known to cause mistakes by programmers
raised with languages such as Pascal or Modula-2.
In addition, C++ offers modifying assignments,
which may be used as, for example, in n += 1,
which is identical in meaning to n = n + 1.
Control
Allowing descendants full access to the instance variables
defined by ancestors, however,
increases the dependency on the actual
implementation of these ancestors,
with the risk of a total collapse when the implementation
of an ancestor changes.
Technology
To get some of the flavor of using C++, look at the definition of the ctr class in slide cc-tech-2 employing multiple constructors, operators, default arguments and type conversion.
Again, the difference is most clearly reflected in how
an instance of ctr is used.
This example illustrates that C++ offers
many of the features that allow us to define
objects which may be used in a (more or less)
natural way.
In the end, this is what software development is about,
to please the user, within reason.
draft version 0.1 (15/7/2001)
public:
ctr(int i = 0, char* x = "ctr") {
n = i; strcpy(s,x);
}
ctr& operator++(int) { n++; return *this; }
int operator()() { return n; }
operator int() { return n; }
operator char*() { return s; }
private:
int n; char s[64];
};
Usage
Summary
The language C++
[]
readme
course
preface
1
2
3
4
5
6
7
8
9
10
11
12
appendix
lectures
resources
eliens@cs.vu.nl