This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/26543] friend class declaration inside class scope ignored



------- Comment #3 from pato101 at gmail dot com  2006-03-03 14:26 -------
(In reply to comment #1)
> This is invalid C++.  Use -ffriend-injection to make it work.
> 
Wait, why is it invalid? At Bjarne Stroustrup's "C++ programming language"
third edition, chapter 11, section "11.5 Friends" at its end (page 279) says:
It is not unusual for all functions of one class to be friends of another.
There is a shorthand for this:
class List{
     friend class List_iterator;
     // ...
};

Note furthermore that the "a" class in my example is not causing any trouble
while the syntax is the same than for "c" execpt that it is already declared
above... Why would I use "friend class List_iterator" if "class List_iterator"
is declared above, and I can use just "friend List_iterator" instead?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26543


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]