D
di boruman
Hi,
I would like to let a member a of class A know about the object it
was created in:
A a(this);
'this' would be stored in a member of A, for example
B* b;
for this purpose I included A.h in B.h and B.h in A.h (without
problems) but when I try to declare the 'B* b;' I get a strange
error (error C2501 - the error message is in Japanese
(I use the Japanese version of Visual C++ .NET) and
says something like "even if the identifier was declared,
his shape is unspecified).
here is the miminum code producing the error:
int main(int argc, char* argv[])
{
return 0;
}
class A
{
public:
B* b; // if I comment this line out everything works fine
A(void) {};
~A(void) {};
};
class B
{
public:
// A* a;
B(void) {};
~B(void) {};
};
Actually I would like to also let B know about A, see the comment in
class B...
Is there anybody who can tell me, why this is not possible??
Or even better how it could be possible???
(or why it makes sense to forbid things like this - for the case
it doesn't make sense...)
any help??
Thanks a lot , di
PS: The context of this problem is the following:
I try to implement a little Genetic Algorithm and have a
class 'Individual' with two members: 'Chromosome' and 'Phenotype'.
I want the Phenotype to be able to adress the corresponding
cromosome. As the individual knows about the
chromosome, the easyest way would be to let the phenotype know
about the individual it is belonging to....
I would like to let a member a of class A know about the object it
was created in:
A a(this);
'this' would be stored in a member of A, for example
B* b;
for this purpose I included A.h in B.h and B.h in A.h (without
problems) but when I try to declare the 'B* b;' I get a strange
error (error C2501 - the error message is in Japanese
(I use the Japanese version of Visual C++ .NET) and
says something like "even if the identifier was declared,
his shape is unspecified).
here is the miminum code producing the error:
int main(int argc, char* argv[])
{
return 0;
}
class A
{
public:
B* b; // if I comment this line out everything works fine
A(void) {};
~A(void) {};
};
class B
{
public:
// A* a;
B(void) {};
~B(void) {};
};
Actually I would like to also let B know about A, see the comment in
class B...
Is there anybody who can tell me, why this is not possible??
Or even better how it could be possible???
(or why it makes sense to forbid things like this - for the case
it doesn't make sense...)
any help??
Thanks a lot , di
PS: The context of this problem is the following:
I try to implement a little Genetic Algorithm and have a
class 'Individual' with two members: 'Chromosome' and 'Phenotype'.
I want the Phenotype to be able to adress the corresponding
cromosome. As the individual knows about the
chromosome, the easyest way would be to let the phenotype know
about the individual it is belonging to....