3.2.2 vs. 3.3.2 - forward declaration

Eljay Love-Jensen eljay@adobe.com
Fri Dec 17 16:13:00 GMT 2004


Hi Ilja,

I think your code is running into a situation analogous to this one (see 
code below), but regarding templates instead of simple structures...

//------------------------------------------
class Foo;

struct Bar
{
         Foo foo; // error: field `foo' has incomplete type
};

class Foo
{
public:
         int i;
};

int main()
{
         Bar bar;
}
//------------------------------------------

If you declare the class before you instantiate it, it doesn't generate the 
error.

I'm not sure of the relevant ISO 14882 reference to cite, but I'd bet that 
there's one in there that addresses the situation you've run into.

HTH,
--Eljay



More information about the Gcc-help mailing list