I have a header file with a class template. Since I would like to define its member functions in a different file, I created a .tpp
file for that purpose. Example below:
a.hpp
#ifndef A_HPP
#define A_HPP
template <typename T>
class A {
void foo();
};
#include "a.tpp"
#endif // A_HPP
a.tpp
#ifndef A_TPP
#define A_TPP
// #include "a.hpp" ???
template <typename T>
void A<T>::foo(){ /* function body */ }
#endif // A_TPP
According to this question, it is a good practice to include the header files that are used in the file even if they have been included in previous files. Following that logic, should I include the a.hpp
file in a.tpp
, even if it leads to recursive inclusion (although it doesn't, due to the include guards)?