back to Computational Physics home page

Computational Physics, 1B, Term 2

Package handling examples: one | two

You can download all the files for examples one and two in a single zip file.

First example

The first example shows how to split utility functions off into separate files. It uses these four files.

| makefile | package1.cc | tinyutils.h | tinyutils.cc |

The main program is in package1.cc. It allocates a couple of vectors, does a calculation, prints a vector, and frees the vectors.

The functions called by the main program are all defined in tinyutils.cc.

The function declarations (which are included by both package1.cc and tinyutils.cc are all in the header file tinyutils.cc.

[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]

Second example

This example shows how to use structures too. It performs exactly the same operations as the first example. It uses the same makefile and these three files.

| package2.cc | tinyutils2.cc | tinyutils2.h |

The structure is defined in tinyutils2.h.
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]

Other material. | utils.cc | utils.h | NewDelete.cc |
David MacKay
Last modified: Wed Nov 14 10:11:32 2007