I wrote a code for a circular linked list however I have a problem with an else condition. In my "delete node" part (which I give it below) my compiler does not accept the else (I marked in the code I provided which else is it) I put and states " Expected a statement! ". Please, any piece of advice would be appreciated.
the problem is partially book formatting :)
if you fix the {} to align, rather than the compact textbook style, you can quickly see that there is no if for that offending else.
you have
if(//line 3
else //line 6
... something is missing here..
else //line 23
after using an admittedly obnoxious online formatter to exaggerate what I am saying, see how the 2 elses are at the same level of indent? They were in yours too, but the {} alignment makes it super hard to see which block goes with which statement.
note that else if is just cramming 2 statements on one line, it is common to do that in c++.
That is, "else if" isnt special in c++ (it is in some languages), its just another if inside the else block, written in a friendly to humans way.