开发者

help with doubly linked list?

开发者 https://www.devze.com 2023-02-25 13:41 出处:网络
I have a class LinkedList clas that has a class called Node class Node { public: Node() { next = NULL; prev = NULL; }

I have a class LinkedList clas that has a class called Node

class Node {
public:
Node() { next = NULL; prev = NULL; }
~Node() {}
public :
Node *next;
Node *prev;
T data;


 };

In the same LinkedList class i have the following function defininiti开发者_StackOverflow社区ons, because it is all in a header file

 public:
LinkedList();
~LinkedList();

// methods -- note that the return values are of type T. Don't return a Node!
  void append(T item);
  T get(int idx);
  void insert(int idx, T item);
  void map(T (*pf)(T item));
  T remove(int index);
  int size();
  void unshift(T item);

No I am trying to implement the operations

first i need to return a new, empty Linked List.

please help, i tried many things

would it be as simple as

LinkedList<T>::LinkedList() {

head = NULL;
current = NULL;

}


Would it be as simple as?

LinkedList<T>::LinkedList() {
    head = NULL;
    current = NULL;
}

Yes.

0

精彩评论

暂无评论...
验证码 换一张
取 消