⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.h

📁 一个进行整数计算的C语言词法分析器
💻 H
字号:
#include <stdlib.h>
#include <iostream.h>
template <class T>
class Node
{    
	Node<T> * next; //next 是下一个结点的地址
public:
	T data; 	// the data is public
    Node(const T& item, Node<T>* ptrnext=NULL);
      // list modification methods
    void InsertAfter(Node<T> *p);
    Node<T> * DeleteAfter(void);
      // obtain the address of the next node
    Node<T> * NextNode(void) const;
};
//有参构造函数
template <class T>
Node<T>::Node(const T& item, Node<T>* ptrnext) : 
data(item), next(ptrnext){ }

// return value of private member next
template <class T>
Node<T>* Node<T>::NextNode(void) const
{
    return next;
} 
// insert a node p after the current one
template <class T>
void Node<T>::InsertAfter(Node<T> *p)
{
  // p points to successor of the current 
  // node, and current node  points to p.
    p->next = next;
    next = p;
}
// delete the node following current and return its address
template <class T>
Node<T>* Node<T>::DeleteAfter(void)
{ // save address of node to be deleted
    Node<T>* tempPtr = next;
  // if there isn't a successor, return NULL
    if (next == NULL) return NULL;
  // current node points to successor of tempPtr.
    next = tempPtr->next;
  // return the pointer to the unlinked node
    return tempPtr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -