What is the difference between a friend iterator and an iterator of a friend class that comes across thinking in C ++?

In Thinking in C ++ Volume 1, Chapter 16: Introduction to Templates. Context:

Note 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 scope from the included file.

What does Eckel really mean above? The friend iterator seems to be compiling correctly, and I see no difference. Can anyone tell an answer? Thanks

+7
source share
1 answer

According to the standard section of C ++ 03 11.4:

The specifier of the specified type must be used in a friend declaration for the class.

So, according to the specification, the compiler will warn you that the iterator friend declaration should be a qualified class name. If not, complier does not meet the standard in this particular aspect.

What are Designed Type Specifiers ?
C ++ uses developed type specifiers to explicitly tell the compiler to treat a class as a class. I think MSDN can explain this a lot better than I can, so see this for a detailed explanation.

+6
source