Visibility problem with nested classes
SXTHREE
sxthree@penfeld.tls.mms.fr
Fri Mar 20 02:55:00 GMT 1998
I'm using egcs-1.0.2 "gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)"
on a Sparc host running Solaris-2.5.1 and I noticed a problem: following
code produces an error:
#include <iostream.h>
class foo {
public:
class bar;
int func(bar *);
class bar {
int st;
public:
bar(){st=12;}
~bar(){}
friend int foo::func(bar *);
};
foo(){}
~foo(){}
};
int foo::func(bar *b) {
return b->st;
}
int main() {
foo x;
foo::bar y;
cout << x.func(&y) << endl;
return(0);
}
the error generated:
bug2.8.0-1.cc:13: member `foo::func(foo::bar *)' declared as friend before type `foo' defined
bug2.8.0-1.cc: In method `int foo::func(class foo::bar *)':
bug2.8.0-1.cc:20: member `st' is a private member of class `foo::bar'
############################
This generates the same behaviour with a linux-gnulibc1 host
and again the same behaviour with gcc-2.8.0 and gcc-2.8.1 releases.
F. Michel
(sxthree@penfeld.tls.mms.fr)
More information about the Gcc-bugs
mailing list