开发者

help with doubly linked list?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜