compilation problem

Hi to all,

I need to compile a kind of program like this one:

1
2
3
4
5
6
7
class a;
class b;

class a { b b1;};
class b { a a1;};

int main(int argc, char *argv[]) { return 0; }


and i get this error message :
error: field 'b1' has incomplete type

is there some issue to get it working ?

Thank you.
class a { b* b1;};
ok, its better thank you, but now I'm stuck with a :

error: invalid use of incomplete type 'struct a'
error: forward declaration of 'struct a'

for this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class a;
class b;

class b
{
public:
    a *a1;
    b()
    {
        a1 = new a();
    }
};
class a
{
public:
    b *b1;
    a()
    {
        b1 = new b();
    }
};


void main(int argc, char *argv[])
{
    a my_a;
    b my_b;
}
Topic archived. No new replies allowed.