Thank you for both for your help. The "PhoneNumber.h" line is used for the class defined in that header file. It works fine using my top code but not using the bottom one. Here is a picture of the error message:
You need to move the implementation of writeDots out of the header file into a .cpp file, or declare it inline.
It's being compiled in each .cpp file that the header file appears in, and the linker doesn't know which implementation to choose as it's expecting just one version of the function.