Guest User

Untitled

a guest
Dec 13th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. void addToList(int dataToAdd){
  2. Node nodeToBeAdded(dataToAdd, NULL); //initilize the node we are going to add with the data that was given by the user
  3.  
  4. if(this->getHead() == NULL){
  5. this->setHead(&nodeToBeAdded);
  6. cout << "Added " << this->getHead()->getData() << " to the head of the listn";
  7. return;
  8. }
  9. //Calls this even after I set the heads next
  10. else if(this->getHead()->getNext() == NULL){
  11. cout<<"Testn";
  12. this->getHead()->setNext(&nodeToBeAdded);
  13. }
  14. //IT NEVER REACHES THIS
  15. else{
  16. cout<<"super testn";
  17. }
  18.  
  19. }
  20.  
  21. Added 3 to the head of the list
  22. Test
  23. Test
Add Comment
Please, Sign In to add comment