C ++ primer plus:
"Because templates are not functions, they cannot be compiled independently and must be used together with specific template instantiation requests. To do this, the easiest way is to put all template information in a header file and include this header file in the file to use these templates ."
"If the compiler implements the new export keyword, you can place the template method definition in an independent file, provided that each template declaration starts with export:
...... (Omitted)
Export template <class type>
Class Stack
{
...
};
Then follow the regular class method:
1. Place the template declaration (including the keyword export) in a header file and use the # include commandProgramThese statements can be used.
2. Place the method definition of the template class inSource codeFiles that contain header files and use engineering files (or other equivalent files) to enable programs to use these definitions.
"