Advertisement
Loesome

Link.cpp

Apr 4th, 2014
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include "Link.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. template<typename T>
  6. void printLList(Link<T> * list)
  7. {
  8. while(list != 0)
  9. {
  10. cout << list->element << "\n";
  11. list = list->next;
  12. }
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18. /*
  19. List<int> * LinkerHead = new List<int>(1,
  20. new List<int>(1,
  21. new List<int>(1,
  22. new List<int>(1))));
  23.  
  24. List<int> * LinkerHead = new List<int>(1);
  25. LinkerHead->next = new List<int>(2);
  26. LinkerHead->next->next = new List<int>(3);
  27. LinkerHead->next->next->next = new List<int>(4);
  28. */
  29.  
  30. Link<int> * link = new Link<int>(1);
  31. Link<int> * list = link;
  32.  
  33. for(int i = 2;i<100;i++, list = list->next)
  34. {
  35. list->next = new Link<int>(i);
  36. }
  37. printLList(link);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement