我有一个任务,我应该创建在双向链表中插入和删除节点的方法.但是我的C++有点生疏.我的前后指针出错了.
LinkedList.h
#ifndef LinkedList_h
#define LinkedList_h
#include <iostream>
using namespace std;
struct node {
node * prev;
int data;
node * next;
};
class LinkedList {
private:
//pointers to point to front and end of Linked List
static node * front; //the error is coming from here
static node * rear; //the error is coming from here
public:
static void insert_front(int data);
};
#endif
Run Code Online (Sandbox Code Playgroud)
LinkedList.cpp
#include "LinkedList.h"
//insert int to front
void LinkedList::insert_front(int data) {
node *q = nullptr;
//If …Run Code Online (Sandbox Code Playgroud)