问题
I use forward declaration but still get ERROR: 'link' does not name a type. Why?
struct link;
struct node
{
link *head_link; <------- this is the error location
node *next_node;
};
struct link
{
link *next_link;
node *connect_node;
};
回答1:
You declare a type called struct link, it's not just link, so write:
struct node
{
struct link *head_link;
struct node *next_node;
};
Alternatively, declare a type called link with a typedef
.
来源:https://stackoverflow.com/questions/18009716/forward-declaration-not-working-does-not-have-a-type-error