I\'m doing an exercise (from the third chapter of Thinking in C++) but I have a problem linking two .cpp files.
This is the exercise:
Create a h
It looks every beginner is going through this (including myself), in the main.cpp you include the .cpp file and not the .h,
//func_ex_main.cpp
#include "func_ex.cpp" // instead of .h
#include
using namespace std;
//etc...
because the .cpp is linked to the header through the include in that .cpp file, and each function definition is linked to the deceleration through the :: notation before the definition.
Remember that the default constructor and destructor in the .h file is declared and defined automatically (if you didn't override or overload it), which will result in a compile error if you just re-defined it in the .cpp file, so if you didn't want to override it just don't mention the constructor neither the destructor in neither the header nor source files.