Next: Dynamic allocation
Up: October 25
Previous: CPP macros and conditional
C++ overview
The last two assignments in this course will be implemented in C++.
We don't teach C++ in lecture (although there will be a number of
tutorials dealing with it) so you'll need a manual (consider
Stroustrup's The C++ Programming Language or Satir and Brown
C++, the Core Language.
Having said that, let's consider the differences and similarities
between C and C++.
Some similarities:
- C++ is an extension (superset) of C: most C programs are also
C++ programs.
- Basic data types (int, char, float, void) are the same
in C and C++
- You declare variables and functions in the same way.
- A program still has main() outside any class, which is
the starting point for execution. There may be other functions
outside any class.
- preprocessor directives are inherited from C
(#include, etcetera).
Some differences:
- C++ has an additional streamed I/O facilitiy (cout,
cerr etc.). We won't go there, but keep using stdio.h
- dynamic memory allocation adds features to make it easier.
- C++ has classes
- C++ allows the // form of comment (lasts until the end
of the currentline).
- struct foo ...; creates a type foo --
declarations foo a; and struct foo a; both work.
- You can mix declarations and other statements.
Next: Dynamic allocation
Up: October 25
Previous: CPP macros and conditional
Danny Heap
2002-12-16