Create a class “Node” which is a single node of a singly linked list. The node stores an integer datatype. The class has two data members, an integer and pointer to the same Node class. Implement the following methods: 1. The default constructor: Set value of the data member to zero 2. A parameterized constructor: Node(int a); takes an integer variable and assigns it to the data member of this object. Set next pointer to NULL. 3. Node* GetNextPointer() const; Retun next pointer of this Node
Create a class “Node” which is a single node of a singly linked list. The node stores an integer datatype. The class has two data members, an integer and pointer to the same Node class.
Implement the following methods:
1. The default constructor: Set value of the data member to zero
2. A parameterized constructor: Node(int a); takes an integer variable and assigns it to the data member of this object. Set next pointer to NULL.
3. Node* GetNextPointer() const; Retun next pointer of this Node
4. void SetNextPointer(Node *ptr); Set the next pointer of this node to the ptr that is passed to the function.
5. void SetData(int a); Set data of this node equal to ‘a’
6. int GetData() const; returns the data of this object.
The data member are private whereas the methods are public.
Step by step
Solved in 3 steps with 1 images