-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkedNode.h
More file actions
62 lines (52 loc) · 1.18 KB
/
LinkedNode.h
File metadata and controls
62 lines (52 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by Toby Dragon on 10/24/16.
//
#ifndef LINKEDNODE_H
#define LINKEDNODE_H
#include<iostream>
template<class ItemType>
class LinkedNode {
private:
ItemType item;
LinkedNode<ItemType>* next;
public:
/**
* Constructor. Creates a new LinkedNode object. The next pointer
* defaults to nullptr.
* @param item The item to be stored in the the node
* @return A new LinkedNode.
*/
LinkedNode<ItemType>(ItemType item){
this->item = item;
next = nullptr;
}
/**
* Getter for item.
* @return a reference to the item stored in the node.
*/
ItemType& getItem(){
return item;
}
/**
* Getter for next.
* @return a pointer to the next Node.
*/
LinkedNode<ItemType>* getNext(){
return next;
}
/**
* Setter for item.
* @param newItem Item to replace the current item.
*/
void setItem(ItemType newItem){
item = newItem;
}
/**
* Setter for next.
* @param newNext A pointer to the node to replace the current next.
*/
void setNext(LinkedNode<ItemType>* newNext){
next = newNext;
}
};
#endif //LINKEDNODE_H