The sixth chapter of C + + Template says this question
There are three ways to organize your template code
1. Include the model (general notation writes the implementation in the header file)
2. Explicit instantiation (Implementation written in CPP file, explicitly instantiated using template class syntax)
3. Detach the model (export using the C + + export keyword Declaration)
The third approach is theoretically optimal, but the main compiler has not supported it since the C + + standard, and has abolished this feature in the latest C++11 standard, and the Export keyword remains pending.
Then there is only an explicit instantiation of the implementation separation that can actually be used
Interestingly, the author of the C + + Template suggested that the code be prepared for the separation model, waiting for the compiler to replace it, and unexpectedly this feature was discarded by the C + + standard.
Tang Yu
Links: http://www.zhihu.com/question/20630104/answer/80220897
Source: Know
Copyright belongs to the author, please contact the author for authorization.
How can a normal compilation be achieved after the template class declaration header file and the implementation file are detached in C + +?