Question & Answer: In C++ Define a class which is a double linked list. Each node of the list contains an integer and long value w…..

In C++ Define a class which is a double linked list. Each node of the list contains an integer and long value which can only be accessed from the class. Your class should include at least three constructors, a getter for the integer and a setter for the long and a destructor. The destructor should claim back the entire memory for an instance of the class.

Expert Answer

 

#include <iostream>

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: In C++ Define a class which is a double linked list. Each node of the list contains an integer and long value w…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

using namespace std;

struct node{

int x;

long y;

struct node *previous;

struct node *next;

};

class llist

{

private:

node *head;

 

public:

 

llist()

{

head = NULL;

}

llist(struct node* n)

{

head = n;

}

llist(int xvalue,long yvalue)

{

head-> x = xvalue;

head->y = yvalue;

}

int getx()

{

return head->x;

}

void setY(long lg)

{

head->y = lg;

}

~llist()

{

delete head;

}

 

};

Still stressed from student homework?
Get quality assistance from academic writers!