Need Help with push back function in a list class i created

I see so i need iterator, , this is what i thought 2 .

Thanks alot
Last edited on
First, there is no need to write this->empty()==true in your if clause, this->empty() is enought. And you don't need to write if(this->empty()==false) in the else, this test is redundant because you can't get here if the list is empty.
Now look at your else clause: you are assigning this->head in the while loop, which means you have lost the head of the list. You have to iterate in the loop with a local variable which first contains the head and not modify the head.
Topic archived. No new replies allowed.