| Thread overview | |||||
|---|---|---|---|---|---|
|
January 02, 2006 Private member accessibility from private class | ||||
|---|---|---|---|---|
| ||||
Hi!
Using 8.45 for code:
class tmPart {
private:
static char sEndl;
struct Endl {
char mEndl;
Endl(char eol) {mEndl = sEndl; sEndl = eol;};
~Endl() {sEndl = mEndl;};
};
};
I'm getting:
test.cpp(6) : Error: member 'tmPart::sEndl' of class 'tmPart' is not accessible
test.cpp(7) : Error: member 'tmPart::sEndl' of class 'tmPart' is not accessible
I'm not sure whether this should be expected or not. Is that fine? Up to now I tested VC, Borland and GCC and they accept it.
Great to see another year with DMC!
ABX
| ||||
January 04, 2006 Re: Private member accessibility from private class | ||||
|---|---|---|---|---|
| ||||
Posted in reply to W³odzimierz Skiba | W³odzimierz Skiba wrote:
> Using 8.45 for code:
>
> class tmPart {
> private:
> static char sEndl;
> struct Endl {
> char mEndl;
> Endl(char eol) {mEndl = sEndl; sEndl = eol;};
> ~Endl() {sEndl = mEndl;};
> };
> };
>
> I'm getting:
>
> test.cpp(6) : Error: member 'tmPart::sEndl' of class 'tmPart' is not accessible
> test.cpp(7) : Error: member 'tmPart::sEndl' of class 'tmPart' is not accessible
>
> I'm not sure whether this should be expected or not. Is that fine? Up to now I tested VC, Borland and GCC and they accept it.
The C++ standard states:
"11.8 Nested classes [class.access.nest]
The members of a nested class have no special access to members of
an enclosing class, nor to classes or functions that have granted
friendship to an enclosing class; the usual access rules (clause 11)
shall be obeyed.
The members of an enclosing class have no special access to members
of a nested class; the usual access rules (clause 11) shall be obeyed."
I think DMC is right.
/b
| |||
January 04, 2006 Re: Private member accessibility from private class | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bertel Brander | "Bertel Brander" <bertel@post4.tele.dk> wrote in message news:dpf7hn$1i60$1@digitaldaemon.com... > I think DMC is right. Thanks for doing the research on this. It's nice to be right <g>. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply