Creating drivers to test classes
In Chapter 5, Exploring Classes in Detail, we briefly talked about breaking our code into source and header files. Let us briefly recap. Typically, the header file will be named after the class (such as Student.h
) and will contain the class definition, plus any inline member function definitions. By placing inline functions in a header file, they will be properly re-expanded should their implementations change (as the header is subsequently included in each source file, creating a dependency with that header).
The implementation for the methods of each class will be placed in a corresponding source code file (such as Student.cpp
), which will include the header on which it is based (that is, #include "Student.h"
). Note that the double quotes imply that this header is in our current working directory; we could also specify a path as to where to find the header. By comparison, the angle brackets used with C++ libraries tell the preprocessor...