1. 首页
  2. 数据库
  3. 其它
  4. C++利用链表写一个简单的栈实例详解

C++利用链表写一个简单的栈实例详解

上传者: 2021-01-03 21:18:28上传 PDF文件 35.12KB 热度 4次
C++中其实有stack的模板类。功能更为强大。 自己写一个栈能让我们对栈这种数据结构更加熟悉。这个栈有一个不足之处就是里面存放的元素类型只能为int。 #include using namespace std; class Stack { private: struct Node { int data; Node *next; }; Node *head; Node *p; int length; public: Stack() { head = NULL; length = 0; } voi
下载地址
用户评论