From: fabio.lombardelli on

red floyd ha scritto:

> FWIW, Comeau online complains about an incomplete type at the point of
> instantiation.
>
> "ComeauTest.c", line 4: error: incomplete type is not allowed
> typedef typename D::_DType DType;
> ^
> detected during instantiation of class "Base<D> [with
> D=Derived]" at
> line 12
>

yes, it's the right behavior maybe.
But I can't understand why it works with methods and not with
typedefs....


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Mathias Gaunard on
fabio.lombardelli(a)gmail.com wrote:

>>> can somebody explain me why this piece of code doesn't compile?
>>> In particular, why the compiler (on Base<Derived> class) can see _fun,
>>> and why it can't see _DType?

This is what happens as far as I understand it.

Because of inheritance, Base<Derived> is defined before Derived.
As a result, Derived is incomplete in the definition of Base<Derived>.

The definition of Base<Derived>::fun, though, happens after the
definition of Derived, making Derived::_fun visible.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]