In C++ Define a class which is a double linked list. Each node of the list conta
ID: 3867679 • Letter: I
Question
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. 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. 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.Explanation / Answer
#include <iostream>
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;
}
};