热门

最新

红包

立Flag

投票

同城

我的

发布
2301_81111390
我是大聪明aeiken
1 年前
true2301_81111390

#include <iostream>
using namespace std;


template <class T>
class Node {
private:
Node<T>* next;
public:
T data;
Node() {data = 0; next = NULL;}
Node(const T& data, Node<T>* next = 0);
void insertAfter(Node<T>* p);
Node<T>* deleteAfter();
Node<T>* nextNode();
};

// 实现构造函数和其余3个功能函数
/********** Begin **********/
template <class T>
Node<T>::Node(const T& data, Node<T>* next) {
this->data = data;
this->next = next;
}

template <class T>
void Node<T>::insertAfter(Node<T>* p) {
p->next = this->next;
this->next = p;
}

template <class T>
Node<T>* Node<T>::deleteAfter() {
Node<T>* tempPtr = next;
if (next == NULL) {
return NULL;
}
next = tempPtr->next;
return tempPtr;
}

template <class T>
Node<T>* Node<T>::nextNode() {
return next;
}
/********** End **********/

CSDN App 扫码分享
分享
1
点赞
打赏
  • 复制链接
  • 举报
下一条:
这把火来势汹汹,我相信星星之火可以燎原
立即登录