Skip to content

Instantly share code, notes, and snippets.

@easleyschool
Created October 10, 2019 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easleyschool/58067ef15cc12efad9d6b39b97078b5f to your computer and use it in GitHub Desktop.
Save easleyschool/58067ef15cc12efad9d6b39b97078b5f to your computer and use it in GitHub Desktop.
/*
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