I'm in CS2 and we're just learning about linked lists and I have to code the parameterized constructor of a linked list class (node based). I don't really understand the node lists, so any help of what's going on here or how to approach would be helpful! I have the following Node class given:
class Node {
friend class NodeList;
public:
Node() : m_next(NULL) {}
Node(const DataType& data, Node* next = NULL) :
m_next(next), m_data(data) {}
Node(const Node& other) : m_next(other.m_next),
m_data(other.m_data) {}
DataType& data() { return m_data; }
const DataType& data() const { return m_data; }
private:
Node* m_next;
DataType m_data;
};
and I'm trying to create the parameterized constructor for the following class:
Class NodeList {
public:
NodeList();
NodeList(size_t count, const int value);
private:
Node* m_head;
}
, where the parameterized constructor is supposed to have 'count' nodes initialized to 'value'.
Thank you!