mine compiled fine with warning and error flags. you should also probably have a look at the prioritization of your code. you are declaring members of "nodes" and traversing to other "nodes" which are non-existent.

As much as I love to initialise to zero, in this situation it is not needed.

node* head = new node;

Similarly, this is redundant.

node* tmp = head;tmp = new node;

Instead, we can just do.

node* tmp = new node;

I can understand in C89 that variables have to be declared at the top of the block statement. That is where it would be useful to initialise to zero. In C++, if we know what we are initialising it to then it's useless to do anything else.

1

C++

131,060 followers

About

Used in many types of software including music players, video games, and many large scale applications.