private structure

A

Ahmed Ossman

Hi all,
I have a question here:
Following is the code:

class x {
private:
typedef int myint;

struct mystr {
myint stInt; <<<<< The Compiler said here that: x:: myint can
not be accessable from x::mystr , whyy???
}

struct mystr2{
x::mystr strInstant; <<<<< The Compiler said here that: x::mystr
can not be accessable from x::mystr2 ????

}
}

could any one help.
BTW: I use Compiler:
Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09

Thanks in advance,

Ahmed Ossman
 
R

Ron Natalie

Ahmed Ossman said:
Hi all,
I have a question here:
Following is the code:

class x {
private:
typedef int myint;

struct mystr {
myint stInt; <<<<< The Compiler said here that: x:: myint can
not be accessable from x::mystr , whyy???
}
You're missing semicolons.

Defining a structure inside a class just defines the type name in that context.
It doesn't convey any special access to the enclosing class.

11.8 is pretty clear:

The members of a nested class have no special access to members of the enclosing
class.

An example that follows shows the same thing you are trying to do as an error.
 

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

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top