Hello~
I want to understand the principle of double circular linked list.
I will show you C++ code. (Code is so long)
I have to implement 'List.cpp' but this is so difficult to me.
* Node.h
#ifndef _NODE_H_
#define _NODE_H_
#include <iostream>
using namespace std;
class Node{
private:
int data;
Node *next;
Node *prev;
public:
Node(int );
~Node();
void Set_next(Node *);
void Set_prev(Node *);
Node* Get_next();
Node* Get_prev();
void Set_data(int);
int Get_data();
void Print();
};
#endif
* List.h
#ifndef _LIST_H_
#define _LIST_H_
#include "Node.h"
class List{
private:
Node *Head;
public:
List();
~List();
void InFt(int );
void InBk(int );
bool DelFt(int &);
bool DelBk(int &);
void Sort();
void ShowFt();
void ShowBk();
};
#endif
* Node.cpp
#include "Node.h"
Node::Node(int data){
this->data = data;
this->next = NULL;
this->prev = NULL;
}
Node::~Node(){
cout<<data<<" is deleted"<<endl;
}
void Node::Set_next(Node *next){
this->next = next;
}
void Node::Set_prev(Node *prev){
this->prev = prev;
}
Node* Node::Get_next(){
return next;
}
Node* Node::Get_prev(){
return prev;
}
void Node::Set_data(int data){
this->data = data;
}
int Node::Get_data(){
return data;
}
void Node::Print(){
cout << data << " " ;
}
* List.cpp
#include "List.h"
List::List(){
this->Head = NULL;
}
void List::InFt(int data){
}
void List::InBk(int data){
}
The more code is remained. But I just want to begin the first function(InFt).
I understood the principle of linked list in one-way(not double circular). But I can not understand 'double circular linked list'. Please help me~