Advertisement
kamyszek

Untitled

Dec 9th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include "list.h"
  2.  
  3. template <class T> List<T>::List() {
  4.     this->next = NULL;
  5. }
  6.  
  7. template <class T> List<T>::List(List *next) {
  8.     this->next = next;
  9. }
  10.  
  11. template <class T> void List<T>::add(T element) {
  12.     if(element*!=NULL) {
  13.         List *newList = new List;
  14.         element = List;
  15.     } else {
  16.         List *newList = new List;
  17.         newList->next = NULL;
  18.     }
  19. }
  20.  
  21. template <class T> void List<T>::show() {
  22.     while(List->next != NULL) {
  23.         cout << &List << endl;
  24.     }
  25. }
  26.  
  27. template <class T> bool List<T>::is_empty() {
  28.     if(this->List == NULL) {
  29.         cout << "Lista jest pusta." << endl;
  30.         return true;
  31.     } else {
  32.         cout << "Lista nie jest pusta." << endl;
  33.         return false;
  34.     }
  35. }
  36.  
  37. template <class T> T List<T>::get(int i) {
  38.     for(int j = 0; j <= i; j++){
  39.         List = List->next;
  40.     }
  41.     cout << &List << endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement