C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Zugriffsrechte bei verschachtelten Klassen

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Jens Auer
Guest





PostPosted: Wed Sep 06, 2006 3:15 pm    Post subject: Zugriffsrechte bei verschachtelten Klassen Reply with quote



Hallo,

wie lauten die Regeln im C++-Standard fuer die Zugriffsrechte auf
private Attribute im Falle von verschachtelten Klassen? Im Internet habe
ich z.B. in einer Doku zu einem IBM-Compiler folgendes Beispiel gefunden:
class A {
int x;

class B { };

class C {

// 1
// The compiler cannot allow the following
// declaration because A::B is private:
B b;

int y;
void f(A* p, int i) {

// 2
// The compiler cannot allow the following
// statement because A:Mad is private:
p->x = i;

}
};

void g(C* p) {

// The compiler cannot allow the following
// statement because C::y is private:
// int z = p->y;
}
};

Laut IBM sind die beien Zugriffe 1 und 2 nicht erlaubt, sowohl der gcc
(4.0.3) als auch Intels Compiler (9.1) erlauben den Zugriff.
Back to top
Björn Hendriks
Guest





PostPosted: Thu Sep 07, 2006 2:29 am    Post subject: Re: Zugriffsrechte bei verschachtelten Klassen Reply with quote



Jens Auer wrote:

Quote:
wie lauten die Regeln im C++-Standard fuer die Zugriffsrechte auf
private Attribute im Falle von verschachtelten Klassen? Im Internet habe
ich z.B. in einer Doku zu einem IBM-Compiler folgendes Beispiel gefunden:
class A {
int x;

class B { };

class C {

// 1
// The compiler cannot allow the following
// declaration because A::B is private:
B b;

int y;
void f(A* p, int i) {

// 2
// The compiler cannot allow the following
// statement because A:Mad is private:
p->x = i;

}
};

void g(C* p) {

// The compiler cannot allow the following
// statement because C::y is private:
// int z = p->y;
}
};

Laut IBM sind die beien Zugriffe 1 und 2 nicht erlaubt, sowohl der gcc
(4.0.3) als auch Intels Compiler (9.1) erlauben den Zugriff.

Dieses Beispiel steht genau so (abgesehen von den Namen der Klassen und den
ausführlichen Kommentaren) im Standard (11.8.1), ist also standardkonform.

MfG

Björn
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.