C++ modules
Bjarne Stroustrup
bs at alice.UUCP
Thu May 16 05:06:38 AEST 1985
C++ design concentrates on facilities for defining new types, but it does
provide features that support a "module concept":
(1) An interface can be defined as a .h file containing a set of
declarations (of constants, user-defined types, functions, and variables).
(2) The implementation (definition) of the functions, the definition of
the variables (if any, data is often better left local to a module), and of
operations on objects of the user-defined types are then placed in (one or more)
.c files.
There can of course be several different interfaces (.h files) for the same
implementation.
This looks very much like the "files as modules" idea for C, but there are two
significant differences:
(1) In C++ names are not implicitly exported from or imported
into .c files, so the interface provided by the .h file can be kept honest
and consistent with the .c files providing the implementation and the .c files
using it.
(2) In C++ one can specify arbitrary code to be executed for
initialization and cleanup of a module. (This is done using constructors and
destructors for static objects - this feature is not yet on the university
distribution tape, but it soon will be).
More information about the Comp.lang.c
mailing list