From: fabio.lombardelli on 19 Dec 2006 07:26 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 20 Dec 2006 12:08 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! ]
First
|
Prev
|
Pages: 1 2 Prev: Why no std::back_insert_iterator::value_type? Next: Exception alternatives |