Question: C++ Linked Lists Excercise Node Header File #ifndef NODE_H #define NODE_H template class Node; template class Node { public: T* value; Node *next; Node *prev;

C++ Linked Lists Excercise

C++ Linked Lists Excercise Node Header File #ifndef NODE_H #define NODE_H templateclass Node; template class Node { public: T* value; Node *next; Node

*prev; Node(T val) { } ~Node() { } }; #endif Dynamic List

Header #ifndef DYNAMICLIST_H #define DYNAMICLIST_H #include "node.h" #include using namespace std; template

class DynamicList; template std::ostream & operator &); template class DynamicList { private:

Node Header File

#ifndef NODE_H

#define NODE_H

template

class Node;

template

class Node

{

public:

T* value;

Node *next;

Node *prev;

Node(T val)

{

}

~Node()

{

}

};

#endif

Dynamic List Header

#ifndef DYNAMICLIST_H

#define DYNAMICLIST_H

#include "node.h"

#include

using namespace std;

template

class DynamicList;

template

std::ostream & operator &);

template

class DynamicList

{

private:

Node *head;

public:

DynamicList();

~DynamicList();

void operator+=(const DynamicList &);

void operator+=(const T);

void operator=(const DynamicList &);

bool operator==(const DynamicList &);

bool operator

bool operator>(const DynamicList &);

T operator [](const int);

bool insertNodeAt(const int, const T);

bool deleteNode(T);

friend std::ostream & operator(std::ostream &, const DynamicList &);

};

#endif

CPP Implementation Files

Dynamic List

#include "dynamicList.h"

Main Program

#include

#include "dynamicList.h"

using namespace std;

int main()

{

DynamicList list;

DynamicList list2;

// Append elements and print

// (Ensure this works before continuing with anything else)

for(int i = 1; i

{

list += i;

}

for(int i = 4; i

{

list2 += i;

}

cout

cout

// Append list and print

list += list2;

cout

// Size comparison

if( list2

{

cout

}

// Assignment operator check

list2 = list;

cout

// Subscript operator check

cout

cout

// Insert node

list.insertNode(1,10);

cout

// Delete node

list.deleteNode(3);

cout

}

Need help with implementation of the linked lists

The task will involve the classes Node and DynamicList, located in the given files node.h and dynamiclist.h For this task you will implement the functions provided in the inside the dynamicList.cpp and node.h files given. You are not required to create your own makefile NOTE: the main.cpp provided to you is a very dumbed down version of the one used to test on FitchFork, thus a working main file that matches the provided example output does not guarantee full marks, and as such it is up to you as the student to expand it and test for corner cases. The following classes are required to be implemented: Node Node is the class to store the data for the dynamic list: Member variables T* value A pointer to the node value being stored Node* next A pointer to the next node in the list Node* prev A pointer to the previous node in the list The task will involve the classes Node and DynamicList, located in the given files node.h and dynamiclist.h For this task you will implement the functions provided in the inside the dynamicList.cpp and node.h files given. You are not required to create your own makefile NOTE: the main.cpp provided to you is a very dumbed down version of the one used to test on FitchFork, thus a working main file that matches the provided example output does not guarantee full marks, and as such it is up to you as the student to expand it and test for corner cases. The following classes are required to be implemented: Node Node is the class to store the data for the dynamic list: Member variables T* value A pointer to the node value being stored Node* next A pointer to the next node in the list Node* prev A pointer to the previous node in the list

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!