Created
October 10, 2019 03:48
-
-
Save easleyschool/58067ef15cc12efad9d6b39b97078b5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Below is the definition of the Node. | |
*/ | |
class Node | |
{ | |
private: | |
// our linked list will only hold int data | |
int data; | |
//pointer to the next node | |
node* next; | |
public: | |
// default constructor | |
Node() | |
{ | |
data = 0; | |
next = NULL; | |
} | |
// parameterised constructor | |
Node(int x) | |
{ | |
data = x; | |
next = NULL; | |
} | |
/* | |
get the value of data | |
*/ | |
int getData() | |
{ | |
return data; | |
} | |
/* | |
to set the value for data | |
*/ | |
void setData(int x) | |
{ | |
this.data = x; | |
} | |
/* | |
get the value of next pointer | |
*/ | |
node* getNext() | |
{ | |
return next; | |
} | |
/* | |
to set the value for pointer | |
*/ | |
void setNext(node *n) | |
{ | |
this.next = n; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment