Think about what a real template is - this is not a real thing, but instructions on how to create real things.
In the case of C ++ templates, the header file does not contain the actual one, for example. 'vector', but instructions on how to build vector . Each time we create the source file, which is #include <vector> , the compiler should build a new vector code, perhaps several times, if we create a vector with different template parameters.
The construction of each source file is independent and does not know if you have already built a vector for another source file, so it creates a new one each time.
Johnmcg
source share