Topic: Legal use of class scoping ??
Author: perryman@benelli.uk.tele.nokia.fi (Steven Perryman)
Date: 1996/10/08 Raw View
I have the following classes :
class X { public : typedef int I ; } ;
class Y : public X { } ;
void foo()
{
Y::I i ; // ***
}
Is the line marked *** legal ??
My first impression is that it should be an error, and required to be X::I.
Two versions of g++ (2.6.x and 2.7.x) seem happy with it, but I'm not so
sure.
If it is legal, I'd be grateful if someone could tell me where it states so
(in the ARM, DWP etc) .
Regards,
Steven Perryman
perryman@cpd.ntc.nokia.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 ]
Author: Pete Becker <pbecker@oec.com>
Date: 1996/10/08 Raw View
Steven Perryman wrote:
>
> I have the following classes :
>
> class X { public : typedef int I ; } ;
>
> class Y : public X { } ;
>
> void foo()
> {
> Y::I i ; // ***
> }
>
> Is the line marked *** legal ??
Yes, it is legal.
> My first impression is that it should be an error, and required to be X::I.
Why?
> Two versions of g++ (2.6.x and 2.7.x) seem happy with it, but I'm not so
> sure.
>
> If it is legal, I'd be grateful if someone could tell me where it states so
> (in the ARM, DWP etc) .
I is a name defined in X. All such names are inherited by Y. It's no
different from a data member or a member function.
[ 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 ]