摘要: #include <iostream> #include <ctime>using namespace std;/********************************************************** Description:参数传递:C++ 二叉树的实现以及指针使用注意事项* Author:ADao12* DateTime:2013-05-30 02:27* Compile Environment:win8+vs2012***********************************************************/ 阅读全文
posted @ 2013-05-30 02:35 盗草人 阅读(551) 评论(0) 推荐(0) 编辑
摘要: By SmartPtr(http://www.cppblog.com/SmartPtr/) 说起C++的模板及模板特化, 相信很多人都很熟悉 ,但是说到模板特化的几种类型,相信了解的人就不是很多。我这里归纳了针对一个模板参数的类模板特化的几种类型, 一是特化为绝对类型; 二是特化为引用,指针类型;三是特化为另外一个类模板。这里用一个简单的例子来说明这三种情况:// general versiontemplate<class T>class Compare{public: static bool IsEqual(const T& lh, const T& rh) { 阅读全文
posted @ 2013-05-30 00:44 盗草人 阅读(202) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <ctime>using namespace std;template<typename T>void selectSort(T a, int length){ for (int i = 0; i <= length-2; i++) { int minIndex = i; int minVal = a[i]; for (int j = i+1; j <=length-1; j++) { if (a[j] < minVal) { minIndex = j; minVal = a[j]; 阅读全文
posted @ 2013-05-30 00:19 盗草人 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 此算法乃复习数据结构用,不喜勿喷。。#include <iostream> #include <ctime>using namespace std;template<typename T>void bubbleSort(T a[], int order, int length){ switch (order) { case 0: for (int i = 0; i < length; i++) { for (int j = 1; j < length; j++) { if (a[j-1] > a[j]) { swap(a[j-1], a[j 阅读全文
posted @ 2013-05-30 00:16 盗草人 阅读(233) 评论(0) 推荐(0) 编辑