Structure of a C++ program using classes
- 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
- Test driver for testing a new class definition,
testJarType.cpp in the Cookie Jar
- Prepare a
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
at the Unix prompt, in the directory where you want to do the
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,
- To execute, type the name of the executable file,
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