Unable to declare Global Variables of Struct Class

Sep 9, 2019 at 9:44am
So, I made a structure and then tried to declare global pointers of that struct class. However, my compiler gave error (VS 2019) and didn't let me create them.
Can anyone explain the reasoning behind it?
Here's the structure (it's basically the node of Linked List)

1
2
3
4
5
6
7
8
9
struct node
{
	char data;
	node* right;
	node* left;
	node* up;
	node* down;
};
node *head = NULL, *tail = NULL;


I am getting error on declaration of head and tail there...
Moreover, can anyone tell me the difference between the above declaration and the following declaration?
1
2
3
4
5
6
7
8
struct node
{
	char data;
	node* right;
	node* left;
	node* up;
	node* down;
}*head, *tail;


The compiler allows this declaration which is done immediately after struct definition. But I presume that both of these declarations create Global Pointers so the former way shouldn't cause any issue? Or should it?
Sep 9, 2019 at 10:15am
Please post the error.

Moreover, can anyone tell me the difference between the above declaration and the following declaration?
Apart from setting NULL there is no real different.
Sep 9, 2019 at 10:30am
I tried it again to get the error and apparently, no error is given now. No idea what went wrong the last time.
Sorry for this. and thank you for the reply. This question is solved
Topic archived. No new replies allowed.