This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++ 3.3.1 (cygwin)
- From: Jimen Ching <jching at flex dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 20 Jan 2004 12:27:31 -1000 (HST)
- Subject: g++ 3.3.1 (cygwin)
Hi,
Is the following code legal C++? Because I didn't get any errors, and I'm
expecting to get an error when I access me->test in struct2::func(), since
it's private. Did the standard allow this and I've overlooked it?
class struct1
{
public:
struct1(int i) : s2(this) { test = i; }
void func(int i) { s2.func(i); }
private:
int test;
struct struct2
{
struct1 *me;
struct2(struct1 *s) { me = s; }
void func(int i) { me->test = i; }
};
struct2 s2;
};
int
main()
{
struct1 s1(1);
s1.func(2);
return 0;
}
--jc
--
Jimen Ching (WH6BRR) jching@flex.com wh6brr@uhm.ampr.org