In particular, the definition of a function in a template class is not written in the corresponding. h file
Reference: Http://stackoverflow.com/questions/8752837/undefined-reference-to-template-class-constructor
My understanding:
Detach the function declaration and definition as before,But I met a strange mistake. Googlebefore we know: the template class just tells the compiler how to generate the class, and there is no generated class, in the compilationmain.cppthe time,Buildlist<quadptr>class, where the function islist.hThere are no specific definitions, none are generated, and the compilationList.cpp, the compiler does not know which class to generate and does not generate suchpush_backand so on, which leads to the connection,list<quadptr>::p ush_backand there is no corresponding implementation. There are two solutions, one is to write the definition in. hfile, this compilesmain.cppwhen, becauseinclude.h, a specific function is generated, and the other method is toList.cppfile tells the compiler to generate the class,template class List<quadptr>.
Encountered undefined reference to when writing template