ListNode.cpp 710 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "ListNode.h"
  2. #define nullptr 0x00
  3. // constructor with 0 parameters
  4. ListNode::ListNode() :
  5. ListNode(nullptr, nullptr)
  6. {
  7. }
  8. // constructor with 2 parameters
  9. ListNode::ListNode(void * data, ListNode * next) :
  10. data(data), next(next)
  11. {
  12. }
  13. // Destructor
  14. ListNode::~ListNode()
  15. {
  16. // delete the data it holds only
  17. delete data;
  18. }
  19. // set data the data for this node
  20. void ListNode::set_data(void * data)
  21. {
  22. this->data = data;
  23. }
  24. // get data the data in this node
  25. void * ListNode::get_data(void)
  26. {
  27. return this->data;
  28. }
  29. // set next the node
  30. void ListNode::set_next(ListNode * next)
  31. {
  32. this->next = next;
  33. }
  34. // get the next node
  35. ListNode * ListNode::get_next(void)
  36. {
  37. return this->next;
  38. }