Is this declaration correct in c++?
class Abc
{
struct xyz x;
};
struct xyz
{
Abc abc;
int instances;
};
I receive the following error. error: field 'x' has incomplete type
So, if I have usecase as above, how do I create it?
Is this declaration correct in c++?
class Abc
{
struct xyz x;
};
struct xyz
{
Abc abc;
int instances;
};
I receive the following error. error: field 'x' has incomplete type
So, if I have usecase as above, how do I create it?
You cannot achieve this because there is a cyclic dependency between the two types. You can achieve this by using pointer to structure as member and forward declarations.