Topic: Using qualified names within a class declaration.


Author: jwbooth@mailcity.com
Date: 1998/03/25
Raw View
In article <6f7pbd$t3n$1@wolfman.xtra.co.nz>,
  "Mark Rodgers" <mark.rodgers@xtra.co.nz> wrote:
   [snip]
> VC++ 5.0 SP2 complains at (1) with "error C2027: use of undefined type
> 'Outer'" but Borland C++ 5.02 compiles it without error.

The following code works in VC++ 4.2:

class Outer
{
 class Base {};
 class Derived;
};

class Outer::Derived : public Base
{
};

Are you able to get Rational Rose to produce the nested classes out-of-line?

Regards,
John.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ 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: "Piet Van Vlierberghe" <pieter.vanvlierberghe@NOSPAM.lms.be>
Date: 1998/03/26
Raw View
Mark Rodgers <mark.rodgers@xtra.co.nz> wrote in article
<6f7pbd$t3n$1@wolfman.xtra.co.nz>...
> Is the following code legal?
>
> class Outer {
>    class Base {};
>    class Derived : public Outer::Base {}; // (1)
> };
>
> VC++ 5.0 SP2 complains at (1) with "error C2027: use of undefined type
> 'Outer'" but Borland C++ 5.02 compiles it without error.
>
> I can't find anything in CD2 that prohibits this but I don't really know
> where to look.

The example is valid.
The paragraph "3.3.1 Point of declaration" says:
4 After the point of declaration of a class member, the member name can be
looked up in the scope of its
class. [Note: this is true even if the class is an incomplete class. For
example,
struct X {
enum E { z = 16 };
int b[X::z]; //ok
};
   end note]
>
> And, yes I know I can get the code to compile by removing the Outer::
> However, the code was generated by Rational Rose so I can't do that.
>
> If it is legal, does anyone know if SP3 has fixed it?  Or do I need
> to beat up Rational?
If any beating is in order, VC++ has it coming. SP3 does not solve your
problem; I tried.
VC++ 5.0 contains *lots* of scope resolution defects. MS is well aware of
these problems
but will not tell when these will be solved (due to their internal policy
8^)
---
[ 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: jpotter@falcon.lhup.edu (John Potter)
Date: 1998/03/27
Raw View
"Piet Van Vlierberghe" <pieter.vanvlierberghe@NOSPAM.lms.be> wrote:

: Mark Rodgers <mark.rodgers@xtra.co.nz> wrote in article
: <6f7pbd$t3n$1@wolfman.xtra.co.nz>...
: > Is the following code legal?
: >
: > class Outer {
: >    class Base {};
: >    class Derived : public Outer::Base {}; // (1)
: > };
: >
: > VC++ 5.0 SP2 complains at (1) with "error C2027: use of undefined type
: > 'Outer'" but Borland C++ 5.02 compiles it without error.
: >
: > I can't find anything in CD2 that prohibits this but I don't really know
: > where to look.

: The example is valid.
: The paragraph "3.3.1 Point of declaration" says:
: 4 After the point of declaration of a class member, the member name can be
: looked up in the scope of its
: class. [Note: this is true even if the class is an incomplete class. For
: example,
: struct X {
: enum E { z = 16 };
: int b[X::z]; //ok
: };
:    end note]

Agreed that the error reported is invalid.

But, Base is a private nested class.  Derived has no special rights to
the private parts of Outer; therefor, it can not derive from it.  I
think that compilers which accept it are cfront bug compatable only.

John
---
[ 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: "Piet Van Vlierberghe" <pieter.vanvlierberghe@NOSPAM.lms.be>
Date: 1998/04/01
Raw View
John Potter <jpotter@falcon.lhup.edu> wrote in article
<6fed03$h1f$1@pigpen.csrlink.net>...
>
> But, Base is a private nested class.  Derived has no special rights to
> the private parts of Outer; therefor, it can not derive from it.  I
> think that compilers which accept it are cfront bug compatable only.
>

It is certainly true that Base is a private nested class. But the access to
base classes in a class declaration depends on the access rights of the
declaration itself, not of the class being declared. So in the example, the
declaration

 class Derived : public Outer::Base {}; // (1)

*is* valid, because Outer::Base is accessible from Outer. It would have
been different altogether if the declaration would have  read

 class Derived { public: Outer::Base base}; // (1)

This would indeed have been illegal.
---
[ 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: "Mark Rodgers" <mark.rodgers@xtra.co.nz>
Date: 1998/03/24
Raw View
Is the following code legal?

class Outer {
   class Base {};
   class Derived : public Outer::Base {}; // (1)
};

VC++ 5.0 SP2 complains at (1) with "error C2027: use of undefined type
'Outer'" but Borland C++ 5.02 compiles it without error.

I can't find anything in CD2 that prohibits this but I don't really know
where to look.

And, yes I know I can get the code to compile by removing the Outer::
However, the code was generated by Rational Rose so I can't do that.

If it is legal, does anyone know if SP3 has fixed it?  Or do I need
to beat up Rational?
--
Mark
mark.rodgers@xtra.co.nz
---
[ 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              ]