Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "List.h"
  4.  
  5. class CppList {
  6.    
  7.     List* _list_ptr;
  8.  
  9. public:
  10.    
  11.     /*
  12.      * Creates an empty CppList.
  13.      */
  14.     CppList()
  15.         : _list_ptr(List_alloc()) {
  16.     }
  17.  
  18.     ~CppList() {
  19.         List_free(_list_ptr);
  20.     }
  21.    
  22.     CppList(const CppList& other) :
  23.         _list_ptr(List_clone(other._list_ptr)) {
  24.     }
  25.    
  26.     CppList& operator=(const CppList& other) {
  27.         if (this!=&other) {
  28.             List_free(_list_ptr);
  29.             _list_ptr= List_clone(other._list_ptr);
  30.         }
  31.         return *this;
  32.     }
  33.  
  34.     void insertFirst(double data) {
  35.         List_insertFirst(_list_ptr, data);
  36.     }
  37.  
  38.     double firstData() const {
  39.         return List_firstData(_list_ptr);
  40.     }
  41.    
  42.     // TODO: make it a global
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement