My understanding was that a friend declaration could also serve as a direct declaration for a class if the class specifier was used, as in this example:
class A { friend class B; B* b; }; class B {}; int main() {}
However g ++ (4.6.3 and 4.7.0) gives me the following error (g ++ - 4.7 should have support for extended friend declarations ), which is expected without a direct declaration:
main.cpp: 6: 2: error: 'B does not name type
In an attempt to confirm my expectations that friend class B; should act as a direct declaration, I found this answer and this answer , but none of them was final (or I could not conclude a lot from them, at least), so I tried to refer to the C ++ 11 standard and found this example:
class X2 { friend Ct;
Based on my reading of the third declaration, my friend class B should be a specified type specifier declaring a new class.
I'm just starting to understand the official standard wording, so something is missing me. What? I do not understand?
c ++ c ++ 11
JaredC Jan 01 '13 at 10:49
source share