C++ is the emerging standard for applications programming and has become a requirement for most programmers in this decade. It is generally speaking a superset of C, at a higher level and of course an object-oriented language. While some of its features (especially operator overloading & inheritance) make it ideal for the concise and high-level expression of mathematical algorithms and hence very attractive for the implementation of scientific codes, the current generation of C++ compilers isn't very good at optimizing C++ code, making it slower than equivalent C and Fortran code most of the time. This is probably going to change soon though. Meanwhile one can still mix C++ and Fortran. C++ compilers are a lot more fussy than C ones so far as correct and consistent prototyping is correct so more attention has to be given to the matter. Make sure to enclose your C prototyping with an extern "C" {}. C++ has a standard complex arithmetic class thus doing away with one of the major disadvantages of C wrt. numerical codes.
% CC c++_program.C -o executable_nameIf you omit -o executable_name the executable binary will be called a.out by default.
% CC c++_program1.C c++_program2.C -o executable_nameor compile them separately and then link the resulting object files (".o" files) together:
% CC -c c++_program1.C % CC -c c++_program2.C % CC c++_program1.o c++_program2.o -o executable_nameIf some of the include files that you require (by # include <include_file.h> statements in your C++ source code) are not in the standard include file search paths the C++ preprocessor cpp (called by the C++ compiler automatically) searches in, you can specify them by the -Iinclude_search_path flag:
% CC -I/usr/local/mpich/include -c mpi.CSimilarly, if some of the librariy functions that your program uses are not to be found among the standard libraries the linker looks in for a C++ program, you have to specify them yourself, sometimes including the path to the library if it not in the standard directory the linker looks in:
% CC mathc++_program1.o mathc++_program2.o -o executable_name -lm % CC mpi.o -o mpi-test -L/usr/local/mpich/lib/IRIX/ch_shmem -lmpi -lmIf you are using a library whose filename is libblas.a, you specify it as -lblas.