I'm trying to compile unsuccessfully a project that has two classes. The class A has class B as a member, and there is a function where send its pointer to class B. I read already a lot of other sites, forum etc an the trick is called Foward Declaration, but seems to not work... Basically the code is this:
#include <stdio.h>
class A
{
public:
B b;
void Init()
{
printf("Init A\n");
b.Init(this);
}
void Ok()
{
printf("OK A!\n");
b.Ok();
}
};
class B
{
public:
A *a;
void Init(A *param)
{
printf("Init B\n");
a = param;
a->Ok();
}
void Ok()
{
printf("OK B!\n");
}
};
int main()
{
A a;
a.Init();
}