By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

access rules and nested classes

P: n/a
The following example (adapted from standard, section 11.8.1)

class E
{
int x;
class I
{
void f(E* p, int i)
{
p->x = i; // error
}
};
};

is illegal because nested class I has no special access to enclosing class
E. E::x is private and therefore p->x is an access error.

Yet Comeau C++, gcc 3.2 and Visual C++ 7.1 all compile it. What is going on?
Has the standard changed recently?

john
Jul 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
It is a bug in these compilers. HP's aCC compiler gives the expected error.
The other vendors are being milder.

"John Harrison" <jo*************@hotmail.com> wrote in message
news:bj************@ID-196037.news.uni-berlin.de...
The following example (adapted from standard, section 11.8.1)

class E
{
int x;
class I
{
void f(E* p, int i)
{
p->x = i; // error
}
};
};

is illegal because nested class I has no special access to enclosing class
E. E::x is private and therefore p->x is an access error.

Yet Comeau C++, gcc 3.2 and Visual C++ 7.1 all compile it. What is going on? Has the standard changed recently?

john

Jul 19 '05 #2

P: n/a

"Ashok Viswanathan" <as***************@hp.com> wrote in message
news:U6****************@news.cpqcorp.net...
It is a bug in these compilers. HP's aCC compiler gives the expected error. The other vendors are being milder.


Actually I found this

http://anubis.dkuug.dk/jtc1/sc22/wg2...efects.html#45

the standard is going to change in this regard. I guess gcc, Comeau and VC++
are anticipating the change while aCC is not.

John
Jul 19 '05 #3

P: n/a
"John Harrison" <jo*************@hotmail.com> wrote in message
news:bj************@ID-196037.news.uni-berlin.de...

Actually I found this

http://anubis.dkuug.dk/jtc1/sc22/wg2...efects.html#45


That's quite a document. I recently decided to part with $18 for the
standard. Can I get my money back? :-) I wonder how many of the
standard-specialists who post here are up with all this.

DW

Jul 19 '05 #4

P: n/a

"David White" <no.email@provided> wrote in message
news:Jn******************@nasal.pacific.net.au...
"John Harrison" <jo*************@hotmail.com> wrote in message
news:bj************@ID-196037.news.uni-berlin.de...

Actually I found this

http://anubis.dkuug.dk/jtc1/sc22/wg2...efects.html#45


That's quite a document. I recently decided to part with $18 for the
standard. Can I get my money back? :-) I wonder how many of the
standard-specialists who post here are up with all this.

DW


I expect most are at least aware of the defect reports. A handy summary of
the important ones would be useful though.

Most of the time I rely on my intuition and experience to answer questions
about C++, thinking that if its an area I don't know anything about then
I'll at least know I don't know. I've made quite a few mistakes recently
though, mostly caused by the language having changed in recent years.

john
Jul 19 '05 #5

P: n/a
"John Harrison" <jo*************@hotmail.com> writes:
"David White" <no.email@provided> wrote in message
news:Jn******************@nasal.pacific.net.au...
"John Harrison" <jo*************@hotmail.com> wrote in message
news:bj************@ID-196037.news.uni-berlin.de...
>
> Actually I found this
>
> http://anubis.dkuug.dk/jtc1/sc22/wg2...efects.html#45


That's quite a document. I recently decided to part with $18 for the
standard. Can I get my money back? :-) I wonder how many of the
standard-specialists who post here are up with all this.

DW


I expect most are at least aware of the defect reports. A handy summary of
the important ones would be useful though.

Most of the time I rely on my intuition and experience to answer questions
about C++, thinking that if its an area I don't know anything about then
I'll at least know I don't know. I've made quite a few mistakes recently
though, mostly caused by the language having changed in recent years.


Note a large portion of the known issues (but, strangely, not #45,
though its resolution has been stable since 04/01) were resolved
in time for C++2003. The 2003 standard should be availible soon.

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.