|
The typename has a double meaning. There is no difference between the two types of usage mentioned in the landlord, but if
template <typename C>
void print2nd (const C&container)
{
if (container.size ()> = 2) {
typename C :: const_iterator iter (container.begin ()); // It must be here, but only add
// typename
........
}
}
The reason is that at any time you want to refer to a nested dependent type name in the template, you must put the typename immediately before it. For details, please refer to effective c ++ clause 42. |
|