![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++数据结构
崖高人远
这个作者很懒,什么都没留下…
展开
-
链表类
#include #include using namespace std; typedef int T; class List { private: struct Node { T data; Node* next; Node(const T& d):data(d),next() { } }; Node* head; int sz; //返回指针引用转载 2012-10-08 23:57:43 · 401 阅读 · 0 评论 -
用数组实现vector
#include using namespace std; //用数组实现Vector typedef int T; class Vector { private: T* data; int sz; int capacity; void expend() { T* tmp = new T[capacity*2]; for (int i = 0; i < sz; i++)转载 2012-10-08 22:40:16 · 739 阅读 · 0 评论 -
直接以操作链表的方式操作节点
#include using namespace std; typedef int T; //节点类 //struct 也称类? struct Node { T data; Node* next; Node(const T& d):data(d),next() { } }; void print(Node* p) { while(p != NULL) { cout d转载 2012-10-08 22:42:33 · 570 阅读 · 2 评论 -
链表类,亲自测试使用成员方法
#include #include using namespace std; typedef int T; class List { private: struct Node { T data; Node* next; Node(const T& d):data(d),next() { } }; Node* head; int sz; Node*& getp转载 2012-10-10 01:19:26 · 467 阅读 · 0 评论 -
中缀表达式转后缀表达式
#include #include using namespace std; const int LEN = 50; typedef char T; class Stack { private: T data[LEN]; int sz; public: Stack():sz() { } void push(const T& d) throw(const char*)转载 2012-10-14 18:35:56 · 562 阅读 · 1 评论 -
继承List类实现栈
#include #include "List.h" using namespace std; typedef int T; class Stack : public List //应该私有继承 { public: void push(const T& d) { push_front(d); } void pop() { pop_front(); } T top()转载 2012-10-14 17:49:07 · 596 阅读 · 0 评论