What is the difference of friend iterator and friend class iterator which encounter in thinking in c++?
In Thinking in C++ Volume 1, chapter 16: Introduction to Templates. The context:
Notice that instead of just saying:
friend iterator; // Make it a friend
This code has:
friend class iterator; // Make it a friend
This is important because the name "iterator" is already in sc开发者_如何学运维ope, from an included file.
What does Eckel really mean above?
It seems friend iterator
compiles correctly and I can't see the differences. Can anyone tell the answer? Thanks
As per C++03 standard section 11.4:
An elaborated-type-specifier shall be used in a friend declaration for a class.
So as per the specification the compiler will warn you that the friend declaration of iterator
must be an elaborated class name. If not then the complier is non-compliant to the standard in this particular aspect.
What are Elaborated Type Specifiers?
C++ use elaborated type specifiers to tell the compiler explicitly to treat a class as a class. I think MSDN can explain it much better than I can, So check this out for detailed explanation.
精彩评论