I'm just starting to learn to use classes in CPP. The idea seems ok but I'm having real problems when the class is put into two different files (.h and .cpp).
The code below is just meant to use a constructor to call a function to set the value of a private variable (I'm aware this could be done in the constructor itself).
Suppose you have a program spread across a number of files and more than one file has an include directive for a class interface file such as yours: #include "Tom_class.h"
Under these circumstances, you can have files that include other files, and these other files may turn include yet other files. This can easily lead to a situation in which a file, in effect, contains the definitions in #include "Tom_class.h" more than once. C++ does not allow you to define a class more than once, even if the repeated definitions are identical.