Question: C++ - Insert a new node, storing a given value, between the first and second node in the calling object. Do not use NULL use

C++ - Insert a new node, storing a given value, between the first and second node in the calling object.

Do not use NULL use nullptr.

This is a singly-Linked list.

Implement function insert as a member function of the class AnyList.

C++ - Insert a new node, storing a given value, between the

#ifndef ANYLIST_H #define ANYLIST_H #include #include // Need to include for nullptr. class Node { public: Node() : data(), ptrToNext(nullptr) {} Node(int theData, Node *newPtrToNext) : data(theData), ptrtoNext(newPtrToNext){} Node* getPtrToNext() const { return ptrToNext; } int getData() const { return data; } void setData(int theData) { data = theData; } void setPtrToNext (Node *newPtrToNext) { ptrToNext = newPtrToNext; } Node(){} private: int data; Node *ptrToNext; // Pointer that points to next node. }; class AnyList {l public: AnyList(): ptr ToFirst(nullptr), count() {} void print() const; void clearlist(); AnyList(); private: Node *ptrToFirst; // Pointer to point to the first node in the list. int count; // Variable to keep track of number of nodes in the list. }; #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!