A
Adam Nielsen
Hi all,
I've recently upgraded my compiler and some of my code no longer works.
I put it through the Comeau online compiler and it came up with the
same errors, so I'm guessing my code is wrong.
I always thought that if you had a recursive object (where two objects
refer to each other) all you had to do was put in a forward declaration
so the compiler knew what was going on. Now it seems this no longer
works. Could anyone please enlighten me as to the correct way I should
be doing this?
The code below demonstrates the problem - it won't compile.
Many thanks,
Adam.
---
struct B;
struct A
{
B getB(void)
{
return B();
}
};
struct B
{
A getA(void)
{
return A();
}
};
int main(void)
{
A a;
B b;
A ba = b.getA();
B ab = a.getB();
return 0;
}
I've recently upgraded my compiler and some of my code no longer works.
I put it through the Comeau online compiler and it came up with the
same errors, so I'm guessing my code is wrong.
I always thought that if you had a recursive object (where two objects
refer to each other) all you had to do was put in a forward declaration
so the compiler knew what was going on. Now it seems this no longer
works. Could anyone please enlighten me as to the correct way I should
be doing this?
The code below demonstrates the problem - it won't compile.
Many thanks,
Adam.
---
struct B;
struct A
{
B getB(void)
{
return B();
}
};
struct B
{
A getA(void)
{
return A();
}
};
int main(void)
{
A a;
B b;
A ba = b.getA();
B ab = a.getB();
return 0;
}