Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Anther inner class question

Reply
Thread Tools

Anther inner class question

 
 
Glen Able
Guest
Posts: n/a
 
      02-10-2004
class Outer
{
typedef int MyInt;

class Inner
{
Outer::MyInt m_thing;
};
};

In this case, when VC sees the declaration of m_thing, it gives the error
"use of undefined type 'Outer'"

Shouldn't this compile OK? I'm assuming there's no special scoping rules
for typedefs are there?

thanks.


 
Reply With Quote
 
 
 
 
Sharad Kala
Guest
Posts: n/a
 
      02-10-2004

"Glen Able" <(E-Mail Removed)> wrote in message
news:c0aooh$cka$1$(E-Mail Removed)...
> class Outer
> {
> typedef int MyInt;
>
> class Inner
> {
> Outer::MyInt m_thing;
> };
> };
>


Which VC?
VC 7 doesn't complain about this code, same with Comeau online.


 
Reply With Quote
 
 
 
 
Glen Able
Guest
Posts: n/a
 
      02-10-2004
> "Glen Able" <(E-Mail Removed)> wrote in message
> news:c0aooh$cka$1$(E-Mail Removed)...
> > class Outer
> > {
> > typedef int MyInt;
> >
> > class Inner
> > {
> > Outer::MyInt m_thing;
> > };
> > };
> >

>
> Which VC?
> VC 7 doesn't complain about this code, same with Comeau online.
>

Sorry, that's VC6. So, I guess that code *is* valid, then. Seems like
there are quite a few scope-related bugs in VC6, no?


 
Reply With Quote
 
Frank Schmitt
Guest
Posts: n/a
 
      02-11-2004
"Glen Able" <(E-Mail Removed)> writes:

> > "Glen Able" <(E-Mail Removed)> wrote in message
> > news:c0aooh$cka$1$(E-Mail Removed)...
> > > class Outer
> > > {
> > > typedef int MyInt;
> > >
> > > class Inner
> > > {
> > > Outer::MyInt m_thing;
> > > };
> > > };
> > >

> >
> > Which VC?
> > VC 7 doesn't complain about this code, same with Comeau online.
> >

> Sorry, that's VC6. So, I guess that code *is* valid, then. Seems like
> there are quite a few scope-related bugs in VC6, no?


Actually, it's not a scope-related bug, but an accessibility problem.
According to the standard, inner classes don't have access to private
members of the outer class (this is considered a defect in the standard,
though - see http://anubis.dkuug.dk/jtc1/sc22/wg2...efects.html#45)
As a workaround, you can either make the typedef public or make Inner a
friend of Outer.

HTH & kind regards
frank

--
Frank Schmitt
quattro research GmbH
e-mail: schmitt NO at SPAM quattro-research !@! dot com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
failing to instantiate an inner class because of order of inner classes Pyenos Python 2 12-27-2006 11:19 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Copying WinXP From one HDD to anther HDD jackman5 Computer Support 3 05-16-2004 04:44 PM
inner classes in python as inner classes in Java Carlo v. Dango Python 14 10-19-2003 08:49 AM
Static inner class not seeing super class method kishan bisht Java 2 07-02-2003 02:15 PM



Advertisments