473,657 Members | 2,953 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 5425
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.c pqcorp.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@provi ded> wrote in message
news:Jn******** **********@nasa l.pacific.net.a u...
"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@provi ded> wrote in message
news:Jn******** **********@nasa l.pacific.net.a u...
"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
3941
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 private members of nesting class. template <typename T> class Container { // NO friendship given to any other public: class ContainerIterator;
9
1536
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
2076
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
16889
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. This works fine if all of the properties are at the top (root level) of the model but I'd like to keep them in nested classes to organize them better. So, for example, part of my data model looks like this (simplified) : public class MainClass
9
1856
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 to the order */ }
6
1800
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 = new Test1();
5
2188
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 ObjectEgg; and have access to particular elements
5
3082
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 not actively denying the syntax non-globally. I would fully support a change to the language to actively forbid a class definition that is not module-level. I don't consider it pollution. If you want it considered "private" to
3
2117
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 decided to use nested class because I realized that it was the most convenient way to implement my need. Since this feature is supported in many languages, I was just surprised that Python did support it only partially, hence my original email. ...
0
8384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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 we have to send another system

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.