error in c++

+2 ahmedtarek mahmoud · January 11, 2015

Post a Reply


Oldest  Newest  Rating
0 c student · January 12, 2015
what's your error?
+1 ahmedtarek mahmoud · January 12, 2015
the area has the red line beneath
0 c student · January 12, 2015
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.
0 Laura Lee · January 12, 2015
There's redundancy in your code.
node* head = 0;
head = new node;

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 ahmedtarek mahmoud · January 12, 2015
thanks all 
  • 1



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

Bucky Roberts Administrator