private members in internal class

G

Glen Able

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.
 
C

Christoph Rabel

Glen said:
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
 
C

Chris \( Val \)

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

Christoph Rabel

Chris said:
|
| 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?
 
C

Chris \( Val \)

| Chris ( Val ) wrote:
| > | > |
| > | 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
 
C

Chris Theis

Glen Able said:
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
 
C

Christoph Rabel

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

Why not ?

Because its private.

Christoph
 
C

Chris \( Val \)

| Chris ( Val ) wrote:
| > |
| > | 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
 
G

Glen Able

Should Outer be allowed to access Inner's m_member or not?
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,422
Latest member
LatashiaZc

Latest Threads

Top