Topic: processing of in-class functions


Author: simonh@swidev.demon.co.uk (Simon Huntington)
Date: Tue, 13 Jul 1993 15:10:13 +0000
Raw View
In-class functions are processed at the end of the class definition so they
can use members that are declared later in the class. ie.

 struct A
  {
  void f(void) {return a;}

  int a;  // f() obviously returns this member
  };


But what about nested classes? Shouldn't in-class functions from nested
classes be processed when the enclosing class is complete? ie.

 struct A
  {
  struct B
   {
   void f ()
        {
            C::c = 1;  // causes an error, C is not defined
       // so the compiler does not know the full
       // member-list of struct A
            }
       };


     static int c;
      };


I think the function B::f should be processed after the definition of all
enclosing classes. Is their a problem with this or some reason why it does
not? Nested classes are related to their enclosing classes usually so it
would be useful.

Any comments much appreciated.


--
Simon Huntington
Software Interrupt Developments. Leeds, UK.




Author: pkt@lpi.liant.com (Scott Turner)
Date: Thu, 15 Jul 1993 13:54:00 GMT
Raw View
In article <742576213snz@swidev.demon.co.uk>, simonh@swidev.demon.co.uk (Simon Huntington) writes:
> Shouldn't in-class functions from nested
> classes be processed when the enclosing class is complete? ie.
>
>     struct A
>     {
>         struct B
>         {
>             void f ()
>             {
>                 C::c = 1;  // causes an error, C is not defined
>                            // so the compiler does not know the full
>                            // member-list of struct A
>             }
>         };
>
>         static int c;
>     };
>
> I think the function B::f should be processed after the definition of all
> enclosing classes.

The C++ standards committee addressed this matter at the March, 1992
meeting in London.  The revised working paper agrees with you.
--
Prescott K. Turner, Jr.
Liant Software Corp. (developers of LPI languages)
959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com