Topic: completly defined object type and nested classes
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1998/08/05 Raw View
Alain Miniussi wrote:
> struct X {
> struct A;
> struct B { int f(A& p) { return p.i; } };
> struct A {int i;};
> };
This one is ok.
> struct X {
> struct A;
> struct B { int f(A& p) { return p.i; } };
> };
>
> struct X::A {int i;};
This one is not: A is incomplete in the definition
of X::B::f(A&).
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Alain Miniussi <miniussi@ilog.fr>
Date: 1998/08/04 Raw View
is the following code correct ?
struct X {
struct A;
struct B { int f(A& p) { return p.i; } };
struct A {int i;};
};
I mean, according to the draft, X is a completly defined
class in the definition of A::B::f. Does this imply that
X::A is also completly defined ? (and that you can use p.i)
What I want to know is if the fact that a class is
completly defined imply that the corresponding nested classes
are completly defined ?
If the answer is yes (i don't think so), what about that code ?:
struct X {
struct A;
struct B { int f(A& p) { return p.i; } };
};
struct X::A {int i;}; // can you ask to the compiler to look
// that class definition then parsing X::B::f ? probably not.
I think the answer is no, but then, the first code is incorrect,
but I can find only one compiler that agree with that answer.
Alain
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]