C++
部分内容参考狄泰软件学院教学课程
天灰易冷
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
智能指针类模板
设计要点: 1、同一片内存空间只能有一个指针指向 2、指针生命周期结束时自动释放堆空间 #ifndef HEAPARRAY_H #define HEAPARRAY_H template <typename T> class SmartPointer { T* m_pointer; public: SmartPointer(T* p=NULL); SmartPointer(const SmartPointer<T>& obj); Sm.原创 2021-04-07 22:33:27 · 169 阅读 · 0 评论 -
堆数组类模板
使用二阶构造申请内存资源,第一阶段为HeapArray<T>* HeapArray<T>::newInstance(int len)这是与资源申请无关的操作,给数组申请内存资源放在第二阶段bool HeapArray<T>::construct() T& operator[](int index);重载数组访问操作符,试对象能想数组那样访问内存空间,非const对象使用这个数组访问操作符 T operator[] (int index) const;con原创 2021-04-07 09:14:18 · 192 阅读 · 0 评论 -
大华相机中的一个模板嵌套
CSingleDisplayDlg::CSingleDisplayDlg(CWnd* pParent /*=NULL*/) : CDialog(CSingleDisplayDlg::IDD, pParent) , _connected(false) , _isGrabbing(false) , _bRunning(false) , _frameCnt(0) , _frameCtrl(false) , _maxFrameCnt(0) , _devListDlg(NULL) , _displ.原创 2021-04-06 08:57:26 · 398 阅读 · 0 评论 -
逆序打印单向链表
#include <iostream> using namespace std; struct Node { int val; struct Node* next; }; Node* List_Create() { Node* list = NULL; Node* slider = NULL; for(int i=0; i<5; i++) { struct Node* n = new Node(); .原创 2021-03-27 11:43:38 · 126 阅读 · 0 评论 -
选择排序 插入排序 冒泡排序 希尔排序
#include <iostream> using namespace std; class sort { private: template <typename T> static void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; } public: template <typename T> stati.原创 2021-03-26 23:06:51 · 114 阅读 · 0 评论 -
模板类中嵌套函数模板、构造函数为模板
#include <iostream> #include <typeinfo> using namespace std; template<typename T1> class Test { public: Test() { cout << "Test()" << endl; } Test(T1 v) { cout << "Test(T1 v)" <.原创 2021-03-25 12:24:38 · 596 阅读 · 0 评论
分享