
数据结构
wt0617
这个作者很懒,什么都没留下…
展开
-
泛型编程
函数模板的语法规则 template关键字用于声明开始进行泛型编程typename关键字用于声明泛指类型template T> //template:告诉编译器开始泛型编程 T>告诉编译器T是一个泛指类型void Swap(T& a,T& b){ T t = b; a = b; b = t;}函数模板的使用 自动类型推导的调用具体类型显示调原创 2018-01-27 19:50:09 · 189 阅读 · 0 评论 -
智能指针
#ifndef SMARTPOINTER_H#define SMARTPOINTER_Hnamespace Lib{template typename T>class SmartPoint{protected: T* m_pointer;public: SmartPoint(T* p = NULL) { m_pointer = p;原创 2018-02-05 21:49:00 · 211 阅读 · 0 评论 -
C++异常简介
C++内置了异常处理的语法元素try…catch… try语句处理正常代码逻辑catch语句处理异常情况try语句中的异常由对应的catch语句处理try语句处理正常代码逻辑,catch语句处理异常情况try{ double r = divide(1,0);}catch(...) //"..."表示处理所有异常{ cout << "Divi...原创 2018-02-12 22:32:52 · 215 阅读 · 0 评论