class node
{
public:
int data()
{
return data_field;
}
node* link()
{
return link_field;
}
private:
int data_field;
node* link_field
};
Suppose we are using the node class definition listed above. Your program is using a node* variable called head_ptr to point to the first node of a linked list (or head_ptr == NULL for the empty list). Write a few lines of C++ code that will print all the integers in the list.
That looks like a homework assignment, which part are you stuck with?
By the way assuming we have a pointer variable head_ptr, you need a while loop to print out the value of each node. When a value is printed out you should move on to the next node. Do not forget to check if the node is nullptr.