Structure of a C++ program using classes
Source files
- Header file for a class definition,
JarType.h in the Cookie Jar example.
- Implementation file for a class definition,
JarType.cpp in the Cookie Jar
example.
- Test driver for testing a new class definition,
testJarType.cpp in the Cookie Jar
example.
Compiling
- Prepare a
Makefile
with all the dependencies between files, and specifying how to
produce the executable file from source files.
- The Makefile has to be in the same directory as the souce files.
- To compile, type
make
at the Unix prompt, in the directory where you want to do the
compilation.
Files produced by the compilation and how to execute
- Object files. For example,
JarType.o contains the object file for
the class JarType.
- The executable file,
testJarType.
- To execute, type the name of the executable file,
testJarType
at the Unix prompt.
- Make sure the executable file has execute permissions. They
should be automatically set by the compiler, but if for whatever
reason they are not, change them using:
chmod +x testJarType
Ileana Streinu