Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Insert a new node, storing a given value, before the last node of the calling object. Do not use NULL use nullptr. This is a

Insert a new node, storing a given value, before the last node of 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.

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

2. What, according to Sergey, was strange at this meeting?

Answered: 1 week ago

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago