Question: HELP WITH C++ CODE.......... How would I implement this code. void List::insert(int index, Planet * p){ //inserts an element at index, increasing the List size

HELP WITH C++ CODE..........

How would I implement this code.

void List::insert(int index, Planet * p){

//inserts an element at index, increasing the List size by 1

//if the insert index is out of bounds, you should append to the end of the list

}

Here is the header file for doubly linked list...

#ifndef LIST_H #define LIST_H #include "Planet.h" #include class Node { friend class List; //allow list class to access private fields private: Planet *planet; Node *next; Node *prev; public: Planet* getPlanet(){return this->planet;} Node(Planet * p); };

class List{ private: Node *head; Node *tail; public: List(); ~List(); void insert(int index, Planet * p); Planet * read(int index); bool remove(int index); unsigned size(); };

#endif

Would appreciate any help!!

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!