This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26543] friend class declaration inside class scope ignored
- From: "pato101 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Mar 2006 14:26:36 -0000
- Subject: [Bug c++/26543] friend class declaration inside class scope ignored
- References: <bug-26543-12302@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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