[C++] A situation of LNK2019 error and its solution

A template is used in the header file of the custom class. When the template was instantiated, the compiler could not find the implementation of the template.
[Method 1]
In the file that uses the template class or template function, #include a .cpp file with the same name as the .h file in which the class definition is placed (that is, the file that implements each function in the class).
[Method 2] (Recommended)
#include a .cpp file with the same name at the end of the .h header file that defines this class.

Guess you like

Origin blog.csdn.net/COFACTOR/article/details/113932538