I am trying to create a structure that has to hold the data of the same struct type. Is this possible?
I can define a pointer to an object of the same type, but not the structure itself.
struct Node
{
vector<string> state;
struct Node *prev;
int id;
Node()
{
}
~Node()
{
}
};
This is possible. But I cannot define like below. The execution gives an error saying "incomplete type is not allowed".
struct Node
{
vector<string> state;
struct Node prev;
int id;
Node()
{
}
~Node()
{
}
};
Is this possible? If it is, what should I do to get rid of the error?
I have seen that this is possible in Java using classes,
public class Vertex implements Comparable{
public Pallet[] bins;
public int cost;
public Vertex parent;
}
Thank you