Hi, I wrote this code with Deitel&Deitel near me and other examples I found on the web, but It doesnt work. Im quite sure that the first problem is from destructor but i dont know the exact reason. The main should show that everything work properly so I didnt post it
I fixed it...
I forgot to put equal firstPtr and lastPtr to the new node in insertO and insert A and I changed if((firstPtr==lastPtr)==0) in if(firstPtr==0 && lastPtr==0) although I cant see the difference ...
Sorry for the fake alarm but thanks for the answer :)
if((firstPtr==lastPtr)==0) vs if(firstPtr==0 && lastPtr==0)
The first evaluates to true anytime firstPtr and lastPtr don't contain the same value. It could be rewritten as: if ( !(firstPtr == lastPtr) ) or if ( (firstPtr == lastPtr) == false). So if firstPtr and lastPtr are 0, then you have: if ( (0 == 0) == false ) or more simply: if ( true == false )
The second evaluates to true only when both firstPtr and lastPtr are null.