Question: #include template class DList{ struct Node{ T data_; Node* next_; Node* prev_; Node(const T& data=T{},Node* next=nullptr, Node* prev=nullptr){ data_=data; next_=next; prev_=prev; } }; Node* front_;

#include
template
class DList{
struct Node{
T data_;
Node* next_;
Node* prev_;
Node(const T& data=T{},Node* next=nullptr, Node* prev=nullptr){
data_=data;
next_=next;
prev_=prev;
}
};
Node* front_;
Node* back_;
public:
DList(){
front_=nullptr;
back_=nullptr;
}
void push_front(const T& data);
void push_back(const T& data);
void pop_front();
void pop_back();
int getData(int data[]) const;
int getReverseData(int data[]) const;
~DList();
};
template
void DList::push_front(const T& data){
}
template
void DList::push_back(const T& data){
}
template
void DList::pop_front(){
}
template
void DList::pop_back(){
}
template
int DList::getData(int data[]) const{
Node* curr=front_;
int numData=0;
while(curr!=nullptr){
data[numData++]=curr->data_;
curr=curr->next_;
}
return numData;
}
template
int DList::getReverseData(int data[]) const{
Node* curr=back_;
int numData=0;
while(curr!=nullptr){
data[numData++]=curr->data_;
curr=curr->prev_;
}
return numData;
}
template
DList::~DList(){
}
template

Complete the push_front(), push_back(), pop_front(), pop_back() and destructor functions for a DList class.

Please answer the above question in C++ code language, thank you!

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!