The declaration and definition of the C ++ template class/template function should be put in the header file. Do not separate the Declaration and definition of the function in the class (for example, in. declare a member function in the H file. define the member function in the CPP file). This will cause a connection error. The template class/Template Function Definition and declaration should be written in a. h file.
For example
Declare a function template <typename T> void fun (t a) in the Class header file );
Then implement the function in another CPP file.
Template <typename T> void fun (t)
{
/* Function implementation */
}
In this way, an error is reported,
The solution is to implement the function directly when declaring the function. Do not write the function implementation in another CPP file, but the structure looks messy.