I have a C++ project containing multiple classes defined in separate .h
and .cpp
files.
As I add more and more classes to the project, I find myself using functions that should be part of a shared library (utility functions).
I tried adding all utility functions in a separate file, and only include it in files that require their use.
That works and the compiler will not complain unless I try to include that utility file in multiple class files. (As long as I only include the file once, and only once).
What can I do to include the utility file in multiple files?
I already tried the compiler declaratives to avoid including more than one copy of the file:
util.h
#ifndef UTIL_H
#define UTIL_H
#include <libraries_used_here>
<< shared functions code here >>
#endif // UTIL_H