473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

private members in internal class

So, given something like

class Outer
{
private:

class Inner
{
private:
int m_member;
};
};

Should Outer be allowed to access Inner's m_member or not?

GCC thinks yes, VC6 thinks no.

thanks!
glen.
Jul 22 '05 #1
8 3594
Glen Able wrote:
class Outer
{
private:

class Inner
{
private:
int m_member;
};
};

Should Outer be allowed to access Inner's m_member or not?


No. Outer isnt allowed to access a private member of a nested class.

hth

Christoph
Jul 22 '05 #2

"Glen Able" <re***********************@hoxtmxail.com> wrote in message
news:c0*******************@news.demon.co.uk...
| So, given something like
|
| class Outer
| {
| private:
|
| class Inner
| {
| private:
| int m_member;
| };
| };
|
| Should Outer be allowed to access Inner's m_member or not?
|
| GCC thinks yes, VC6 thinks no.

Unless 'm_member' is static, or there is some kind of
friendship involved, then no, not without an object of
type 'Inner', with an available accessor.

Cheers.
Chris Val
Jul 22 '05 #3
Chris ( Val ) wrote:
"Glen Able" <re***********************@hoxtmxail.com> wrote in message
news:c0*******************@news.demon.co.uk...
|
| Should Outer be allowed to access Inner's m_member or not?
|
| GCC thinks yes, VC6 thinks no.

Unless 'm_member' is static, or there is some kind of
friendship involved, then no, not without an object of
type 'Inner', with an available accessor.


What do you mean with static? Even if m_member is static it shouldn't be
accessible.

Christoph?
Jul 22 '05 #4

"Christoph Rabel" <od**@hal9000.vc-graz.ac.at> wrote in message
news:40**********************@aconews.univie.ac.at ...
| Chris ( Val ) wrote:
| > "Glen Able" <re***********************@hoxtmxail.com> wrote in message
| > news:c0*******************@news.demon.co.uk...
| > |
| > | Should Outer be allowed to access Inner's m_member or not?
| > |
| > | GCC thinks yes, VC6 thinks no.
| >
| > Unless 'm_member' is static, or there is some kind of
| > friendship involved, then no, not without an object of
| > type 'Inner', with an available accessor.
|
| What do you mean with static? Even if m_member is static it shouldn't be
| accessible.

Why not ?

Cheers.
Chris Val
Jul 22 '05 #5

"Glen Able" <re***********************@hoxtmxail.com> wrote in message
news:c0*******************@news.demon.co.uk...
So, given something like

class Outer
{
private:

class Inner
{
private:
int m_member;
};
};

Should Outer be allowed to access Inner's m_member or not?

GCC thinks yes, VC6 thinks no.


Interesting; which version of GCC thinks so? IIRC VC6 is right on this
point.

Chris
Jul 22 '05 #6
Chris ( Val ) wrote:
"Christoph Rabel" <od**@hal9000.vc-graz.ac.at> wrote in message
|
| What do you mean with static? Even if m_member is static it shouldn't be
| accessible.

Why not ?


Because its private.

Christoph
Jul 22 '05 #7

"Christoph Rabel" <od**@hal9000.vc-graz.ac.at> wrote in message
news:40***********************@aconews.univie.ac.a t...
| Chris ( Val ) wrote:
| > "Christoph Rabel" <od**@hal9000.vc-graz.ac.at> wrote in message
| > |
| > | What do you mean with static? Even if m_member is static it shouldn't be
| > | accessible.
| >
| > Why not ?
|
| Because its private.

Oop's ;-).

My apologies - I missed that it was private.
I need some shut eye <G>.

Cheers.
Chris Val
Jul 22 '05 #8
> > Should Outer be allowed to access Inner's m_member or not?

GCC thinks yes, VC6 thinks no.


Interesting; which version of GCC thinks so? IIRC VC6 is right on this
point.

Chris


It's 2.95 or thereabouts, with some custom bits...

Thanks for all the replies!

Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pmatos | last post by:
Hi all, I have a style question. I've been for long programming in Lisp-like languages and C when I need a low-level language. Now, I'm programming for professional reasons in C++ (which I had...
10
by: Abelardo Vacca | last post by:
Hi, The title sums up the question pretty much. I would like to access all private members of a class including the private members of its base classes.( I already have the ReflectionPermission )...
1
by: yurps | last post by:
what is the difference between class members which are marked with these....? I wonder because I have a namespace with a few different classes... I want to use a method from another...
6
by: Ken Varn | last post by:
I have an ASP.NET application that is calling a custom class that is trying to parse all of the members of my Page object using Type.GetMembers(). The problem that I am having is that private...
3
by: Klaus Löffelmann | last post by:
Hi, how is it possible to have a private class with public members? When doing some reasearch about double buffered paint actions, I stumbled on a class GraphicBufferManager which is declared...
5
by: Paul | last post by:
Hello All, I am new to C# and dot NET in general. The book I am reading uses the term "non-public." I suspect that they don't mean "private", otherwise they would have said so. What is the...
4
by: newbie120 | last post by:
Hi all maybe its just been a long day, but i have a question about call access modifiers in C#. Consider the following code. namespace Application { private class Class1 { int i;
6
by: WXS | last post by:
I know this sounds contrary to the idea of an interface, but read this and see what you think. ----------------------------------------------------------------------------------------- It would be...
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
26
by: Zytan | last post by:
What happens if I do this: static byte MemberFunction() instead of: public static byte MemberFunction() I know I can't access it. But what does it default to? Private? I can't find any code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.