Topic: nested class syntax improvement


Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1998/05/19
Raw View
Stephen Vavasis <vavasis@CS.Cornell.EDU> wrote:
>I find myself using the following kind of declaration a lot:
>
>class Outer {
>  class Nested;
>  friend class Nested;
>  class Nested {
>    // ....
>  };
>};
>
>Apparently the triple-declaration of a nested class is a standard idiom,
>since I find it in Stroustrup 3d ed p. 852.  It would clean up my code
>if I could say:
>
>class Outer {
>  friend class Nested {
>     // ...
>  };
>};

It would clean up your code more to say

  class Outer {
    class Nested;
    friend class Nested;
  };

  class Outer::Nested {
      // ....
  };

--
Nathan Myers
ncm@nospam.cantrip.org  http://www.cantrip.org/
---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Stephen Vavasis <vavasis@CS.Cornell.EDU>
Date: 1998/05/17
Raw View
I find myself using the following kind of declaration a lot:

class Outer {
  class Nested;
  friend class Nested;
  class Nested {
    // ....
  };
};

Apparently the triple-declaration of a nested class is a standard idiom,
since I find it in Stroustrup 3d ed p. 852.  It would clean up my code
if I could say:

class Outer {
  friend class Nested {
     // ...
  };
};

So I would like to propose this kind of declaration as an addition to a
future C++ standard.

-- Steve Vavasis (vavasis@cs.cornell.edu)


[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]