I've been new to C++, and is now going through templates and have encountered this question.
When the template type requires another class, will there be a specific requirement of the header include order?
vector<string> stringVector;
Like this: should we include string
prior to vector
?
I read this (C++ Header order) and it's saying that the header files should be included in the class-requirement order.
However, as this (Template Compilation) indicates, or if it is my misunderstanding, "the compiler generates the code for the specific types given in the template class instantiation", and I think this means that when we are instantiating the stringVector
, the compiler already included string
header, so there should not be a "vector
here is string
required" relationship.
So, which interpretation is right, and which part of my interpretation is right or wrong? Thanks.