473,503 Members | 8,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access rules and nested classes

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
5 5418
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

"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
"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

"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3931
by: CoolPint | last post by:
I read in books that nested class cannot access private members of nesting class and vice versa unless they are made friends. Somehow, my compiler is letting my nested class member functions access...
9
1523
by: John Harrison | last post by:
Both gcc 3.3.1 and VC++ 7.1 compile the following code. struct Outer { struct Inner { int f() { return c; } }; private: static const int c;
6
2068
by: Marco | last post by:
Howdy! Given: public abstract class A { public abstract int A1(int i); private class B { private int B1(int i) { int j;
8
16851
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
9
1847
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added...
6
1785
by: moondaddy | last post by:
I'm new to c# and am wondering if its possible to access members of a nested class. Can someone please advise? Thanks. class Program { static void Main(string args) { try { Test1 obj =...
5
2179
by: ZikO | last post by:
Hi there. I have a problem. I have created nested classes but don't know how to access to inner classes. I know I can create objects: Hen Object; Hen::Nest ObjectNest; Hen::Nest::Egg...
5
3064
by: Calvin Spealman | last post by:
On Wed, Aug 13, 2008 at 11:32 AM, Cousson, Benoit <b-cousson@ti.comwrote: There is no point of nested classes because nested classes _are not_ supported by python. They are simply an artifact of...
3
2107
by: Cousson, Benoit | last post by:
I don't think so; my original email was mainly a question. I do agree that they are other ways to do what I'm trying to achieve; there are always several ways to solve an issue. Few days ago, I...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.