C++ is a directory of C++ examples which illustrate some of the features of the language.
Depending on your computer, you may invoke the C++ compiler by a command like c++, CC, cxx, or g++ (which is the name of the Gnu C++ compiler).
Depending on your compiler, your C++ files may need to have the extension ".C", ".cc", ".cxx", ".cpp" or even ".c++". In particular, Microsoft Visual C++ does not "know" the difference between upper and lower case in file extensions. If you call your file "fred.C", it will think your file is a C file, not a C++ file. For Microsoft Visual C++, always use the file name extension ".cpp"!
For most C++ compilers, it is customary for include files to have the extension ".H".
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
C, C programs which illustrate some of the features of the C programming language.
F77 FORTRAN77 programs which illustrate features of FORTRAN77;
F90 FORTRAN90 programs which illustrate features of FORTRAN90;
MAKEFILES, C++ programs which illustrate the use of MAKEFILES for maintaining a software project;
MATLAB, MATLAB programs which illustrate the use of the MATLAB programming language;
MIXED C++ programs which call a function written in another programming language.
MPI C++ programs which illustrate the use of the MPI application program interface for carrying out parallel computations in a distributed memory environment.
OPEN_MP C++ programs which illustrate the use of the OpenMP application program interface for carrying out parallel computations in a shared memory environment.
ARRAYS is a very simple example of how to set up arrays in C++. In particular, we note that vectors are easy to declare with fixed or dynamic dimensions, but that arrays of dimension 2 or greater aren't easy to declar dynamically. The example shows how to work around by settting up a two dimensional array as a one dimensional vector. Files you may copy include:
COMPLEX_VALUES demonstrates the use of the ANSI COMPLEX class for complex arithmetic. (At the moment, I am having a terrible time just trying to use the assignment operator!) Files you may copy include:
FUNCTION_POINTER shows how a variable can be created which can point to a function; the target of the pointer can be changed so that a different function is indicated. Files you may copy include:
FUNCTION_POINTER_ARRAY shows how a variable can be created which can be an array of pointers to function. Files you may copy include:
FUNCTION_POINTER_ARRAY_NEW shows how a variable can be created which can be a DYNAMICALLY ALLOCATED array of pointers to function. In other words, this is one way to create an array of function pointers whose dimension is not specified in advance. Then the array can be sized with the NEW command and freed with the DELETE command. Files you may copy include:
HELLO is just a "Hello, world!" program. Files you may copy include:
LIMITS prints out some information about the range and accuracy of various numeric types. Files you may copy include:
NOT_ALLOCATED_ARRAYS shows that you should initialize your array pointers to NULL, and reset them to NULL after you delete your arrays. Otherwise, an unallocated or delete array is liable to have a deceptive nonnull value! Files you may copy include:
POISSON solves the Poisson equation on a 2D grid. This program uses dynamically allocated doubly dimensioned arrays.
RANDOM_NUMBERS shows how to use the standard library routines SRANDOM to set the seed and RANDOM to return random numbers. Files you may copy include:
SIZES prints out the sizes of various datatypes. Files you may copy include:
You can go up one level to the C++ source codes.