Topic: Forward declaration of class member functi


Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1996/03/19
Raw View
In article 199603182248040068@msn.com, "Ron Burk" <RonBurk@msn.com> writes:
>I am having difficulty finding language in the draft
>that establishes the legality or illegality of the following:
>
>class Forward;
>
>class Any {
>    friend int Forward::SomeFunc(int SomeArg);
>    };

It is not valid. You cannot mention the name of a class member until the
class definition has been seen. To interpret the qualified-id A::B, the name
B must be looked up in the scope of A. If A has not been defined, the lookup
fails, and A::B must be considered undefined. Refer to chapters 3, 9, and 10
of the draft standard.

If this sort of thing were allowed, you could add members to a class
without modifying the class definition, thus violating the One-Definition
Rule.

---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]