06 2015 档案

希尔排序
摘要:1 /* 希尔排序 */ 2 3 #include 4 #include 5 6 void show(int *p,int length) 7 { 8 printf("\n"); 9 for (int i=0;i=1)// 增量终止的条件19 {20 f... 阅读全文

posted @ 2015-06-24 14:40 Dragon-wuxl 阅读(196) 评论(0) 推荐(0)

堆排序
摘要:1 /* 堆和堆排序 */ 2 3 // 堆排序 查找最大值 最小值速度最快 4 // 数据结构里面的堆 主要是取出极值 5 6 #include 7 #include 8 9 void show(int *p,int n)10 {11 12 for(int i=0;i0... 阅读全文

posted @ 2015-06-24 12:55 Dragon-wuxl 阅读(227) 评论(0) 推荐(0)

插入排序
摘要:1 /* 插入排序 */ 2 3 #include 4 #include 5 6 void main() 7 { 8 int a[10]={1,2,3,4,6,7,8,9,10,5}; 9 int temp=a[9];// 元素 5 10 int j=9;// 记录下标... 阅读全文

posted @ 2015-06-24 10:20 Dragon-wuxl 阅读(192) 评论(0) 推荐(0)

拉格朗日插值查找
摘要:/* 拉格朗日插值查找 */#include#include#define N 1024void search(int a[N],int num){ int tou = 0; int wei = N-1; int zhong; int flag = -1;// 代表找不到 ... 阅读全文

posted @ 2015-06-24 09:18 Dragon-wuxl 阅读(167) 评论(0) 推荐(0)

二分查找
摘要:1 /* 二分查找 */ 2 3 #include 4 #include 5 #define N 1024 6 7 void search(int a[N],int num) 8 { 9 int tou = 0;10 int wei = N-1;11 int zhong... 阅读全文

posted @ 2015-06-24 09:06 Dragon-wuxl 阅读(182) 评论(0) 推荐(0)

斐波那契数组数组法
摘要:1 /* 斐波那契数组数组法 */ 2 3 #include 4 #include 5 6 // 1 1 2 3 5 8 7 8 int get(int i)// 递归 9 {10 if (i==1 || i==2)11 {12 return 1;... 阅读全文

posted @ 2015-06-20 16:16 Dragon-wuxl 阅读(410) 评论(0) 推荐(0)

冒泡排序
摘要:1 /* 冒泡排序最大值沉底 */ 2 3 #include 4 #include 5 6 7 8 void main() 9 {10 int a[10] = {3,5,18,9,23,5,2,1,0,2};11 for (int i=0;i a[i+1])// 对比14 ... 阅读全文

posted @ 2015-06-20 10:48 Dragon-wuxl 阅读(190) 评论(0) 推荐(0)

选择排序
摘要:1 /* 数组实战 */ 2 3 #include 4 #include 5 #include 6 7 void main() 8 { 9 // 越界不一定出错,不越界一定不会发生内存访问冲突 10 int a[5]={1,2,3,4,5}; 11 f... 阅读全文

posted @ 2015-06-20 09:46 Dragon-wuxl 阅读(189) 评论(0) 推荐(0)

快速排序
摘要:1 #include 2 #include 3 4 void swap(int * pi, int *pj)//交换 5 { 6 int temp = *pi; 7 *pi = *pj; 8 *pj = temp; 9 } 10 void show... 阅读全文

posted @ 2015-06-20 07:49 Dragon-wuxl 阅读(167) 评论(0) 推荐(0)

CGI后门服务器开发
摘要:1 /* 服务器开发 */ 2 3 #include 4 #include 5 #include 6 // 重定向输出 7 // 输入 8 void main() 9 { 10 printf("Content-type:text/html\n\n"); 11 ... 阅读全文

posted @ 2015-06-17 15:49 Dragon-wuxl 阅读(284) 评论(0) 推荐(0)

内存异常处理
摘要:1 /* 内存错误异常处理*/ 2 3 #include 4 #include 5 6 using namespace std; 7 8 struct MyStruct 9 {10 double px[1024*1024*128];11 };12 13 void main()14 {... 阅读全文

posted @ 2015-06-16 14:57 Dragon-wuxl 阅读(169) 评论(0) 推荐(0)

模板类与异常
摘要:1 /* 模板处理异常*/ 2 3 #include 4 5 using namespace std; 6 7 template 8 class myarray 9 {10 public:11 myarray(int num)12 {13 if(num ();... 阅读全文

posted @ 2015-06-16 14:38 Dragon-wuxl 阅读(140) 评论(0) 推荐(0)

多态继承虚函数与异常
摘要:1 /* 异常的继承与虚函数 */ 2 3 #include 4 5 using namespace std; 6 7 class print3dbox 8 { 9 public: 10 print3dbox(int num) 11 { 12 ... 阅读全文

posted @ 2015-06-16 14:21 Dragon-wuxl 阅读(99) 评论(0) 推荐(0)

类嵌套处理异常
摘要:1 /* 类嵌套处理异常 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 9 class print3dbox 10 { 11 public: 12 print3dbox(int a,int b,in... 阅读全文

posted @ 2015-06-16 11:20 Dragon-wuxl 阅读(244) 评论(0) 推荐(1)

类中处理异常
摘要:1 /* 数组类的异常 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 class memerror 9 {10 };11 12 class powererror13 {14 };15 16 class myArray17 {1... 阅读全文

posted @ 2015-06-16 10:38 Dragon-wuxl 阅读(88) 评论(0) 推荐(0)

.最简单的异常CPP实现
摘要:1 /* 纯CPP异常 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 // try 存放有可能触发异常的程序 9 // throw 抛出异常 终止当前代码块继续执行 避免程序崩溃 throw可以抛出任何类... 阅读全文

posted @ 2015-06-16 09:39 Dragon-wuxl 阅读(196) 评论(0) 推荐(0)

hash_set与hash_map
摘要:1 // hash_set 2 3 #include 4 #include 5 6 using namespace std; 7 8 void main() 9 { 10 hash_set myset;// 不会排序 存入哈希表 11 myset.inse... 阅读全文

posted @ 2015-06-14 18:04 Dragon-wuxl 阅读(142) 评论(0) 推荐(0)

map红黑树映射节点为节点或链表
摘要:1 // map 2 3 #include 4 #include 5 6 using namespace std; 7 8 void main() 9 { 10 map mymap; 11 mymap["师长"] = 8; 12 mymap["旅长"... 阅读全文

posted @ 2015-06-14 17:39 Dragon-wuxl 阅读(269) 评论(0) 推荐(0)

set红黑树集合节点为节点或者链表
摘要:1 // set 2 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 void main() 10 { 11 set myset = {1,2,10,4,6}; 12 13 mys... 阅读全文

posted @ 2015-06-14 16:57 Dragon-wuxl 阅读(283) 评论(0) 推荐(0)

二进制bitset
摘要:1 // bitset 2 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 void main()10 {11 bitset mybit(255);// 主要用于位操作12 13 for(int i=... 阅读全文

posted @ 2015-06-14 15:43 Dragon-wuxl 阅读(132) 评论(0) 推荐(0)

字符串结构
摘要:1 // string 2 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 void main()10 {11 string str1 = "ABC";12 string str2 = "XYZ";... 阅读全文

posted @ 2015-06-14 15:04 Dragon-wuxl 阅读(142) 评论(0) 推荐(0)

链式队列数组队列优先队列以及非基本数据类型
摘要:1 // queue 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 10 // queue stack 默认都是deque线性实现11 // 可以强行指定list链式存储12 /... 阅读全文

posted @ 2015-06-14 14:28 Dragon-wuxl 阅读(142) 评论(0) 推荐(0)

链式栈与数组栈
摘要:1 // stack 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 void main() 9 {10 // stack 底层是deque11 // stack 没有迭代器12 stack ... 阅读全文

posted @ 2015-06-14 10:31 Dragon-wuxl 阅读(119) 评论(0) 推荐(0)

deque双端队列
摘要:// deque 线性#include#includeusing namespace std;void main(){ deque myd = {1,2,3,4,5,6}; myd.push_back(13);// 尾部插入 myd.push_front(0);// 前端插入 ... 阅读全文

posted @ 2015-06-14 10:10 Dragon-wuxl 阅读(128) 评论(0) 推荐(0)

线性存储与链式存储迭代器的不同
摘要:1 /* 线性存储与链式存储迭代器的不同 */ 2 3 /* 容器: 4 8 */ 9 10 11 12 #include13 #include14 15 using namespace std;16 17 // vector18 void main()19 {20 vect... 阅读全文

posted @ 2015-06-14 08:56 Dragon-wuxl 阅读(158) 评论(0) 推荐(0)

final与override
摘要:1 /* final与override */ 2 3 #include 4 5 6 using namespace std; 7 8 class myclass 9 {10 public:11 virtual void run()12 {13 14 }15 16 ... 阅读全文

posted @ 2015-06-14 08:25 Dragon-wuxl 阅读(122) 评论(0) 推荐(0)

线性容器
摘要:1 /* 线性容器 */ 2 3 4 #include 5 #include 6 #include// 栈上的数组 7 #include// 堆上的数组 8 #include// 双链表 9 #include// 算法 10 11 using namespace std; ... 阅读全文

posted @ 2015-06-13 14:51 Dragon-wuxl 阅读(229) 评论(0) 推荐(0)

STL四大重要组件
摘要:1 /* STL四大重要组件 */ 2 3 4 #include 5 #include 6 #include 7 #include 8 9 using std::function;// 使用仿函数 10 11 using namespace std; 12 13 // ... 阅读全文

posted @ 2015-06-13 10:07 Dragon-wuxl 阅读(287) 评论(0) 推荐(0)

类成员函数
摘要:1 /* 类成员函数 */ 2 3 4 #include 5 6 using namespace std; 7 8 // 类成员函数指针 类成员二级函数指针 类成员函数指针数组 9 10 11 class op12 {13 public:14 op(int x,int y):a... 阅读全文

posted @ 2015-06-12 17:46 Dragon-wuxl 阅读(171) 评论(0) 推荐(0)

类模板与静态函数
摘要:1 /* 类模板与静态函数 */ 2 3 /* 类模板静态函数 */ 4 5 #include 6 7 using namespace std; 8 9 // 类,类模板的静态成员函数不可以访问this10 // 类模板没有实例化 没有调用就不会编译11 12 template13 cla... 阅读全文

posted @ 2015-06-12 17:14 Dragon-wuxl 阅读(421) 评论(0) 推荐(0)

类模板与静态成员
摘要:1 /* 类模板与静态成员 */ 2 3 4 // 对于static成员,每一个实例化的类的静态成员都是互相独立的 5 6 #include 7 8 using namespace std; 9 10 template11 class myclass12 {13 public:14 ... 阅读全文

posted @ 2015-06-12 16:34 Dragon-wuxl 阅读(123) 评论(0) 推荐(0)

友元实战访问类模板
摘要:1 /* 友元实战访问类模板 */ 2 3 #include "dialog.h" 4 #include 5 #include 6 #include 7 8 template 9 class mywindow10 {11 private:12 T *p;13 void sh... 阅读全文

posted @ 2015-06-12 16:20 Dragon-wuxl 阅读(102) 评论(0) 推荐(0)

类模板友元类以及友元类模板
摘要:1 /* 类模板友元类以及友元类模板 */ 2 3 #include 4 5 using namespace std; 6 7 template class myclass;// 类的存在说明 8 class runit;// 类的存在说明 9 template class runall;/... 阅读全文

posted @ 2015-06-12 16:10 Dragon-wuxl 阅读(138) 评论(0) 推荐(0)

类模板与友元
摘要:1 /* 类模板与友元 */ 2 3 #include 4 5 using namespace std; 6 7 templateclass myclass;// 声明友元类的存在 8 templatevoid show(myclass my);// 友元函数的声明 9 10 templat... 阅读全文

posted @ 2015-06-12 15:34 Dragon-wuxl 阅读(113) 评论(0) 推荐(0)

抽象模板类的用途
摘要:1 #include "dialog.h" 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 //模板可以让类与数据类型无关,泛型的概念 9 //多态,一个接口,可以无限拓展,实现软件的可定制可拓展10 11 template... 阅读全文

posted @ 2015-06-12 14:43 Dragon-wuxl 阅读(122) 评论(0) 推荐(0)

模板与普通类的多态
摘要:1 /* 模板与普通类的多态 */ 2 3 #include 4 5 using namespace std; 6 7 // 类继承于类模板 8 9 // 类模板继承于类,仍然存在多态机制10 11 12 class myclass13 {14 public:15 int x;16... 阅读全文

posted @ 2015-06-12 12:25 Dragon-wuxl 阅读(96) 评论(0) 推荐(0)

模板的继承多态以及多继承多态
摘要:1 /* 模板的继承多态以及多继承多态 */ 2 3 #include 4 5 using namespace std; 6 7 template 8 class myclass 9 {10 public:11 myclass(T a,T b):x(a),y(b)12 {1... 阅读全文

posted @ 2015-06-12 11:01 Dragon-wuxl 阅读(169) 评论(0) 推荐(0)

类模板与类的相互继承
摘要:1 /* 类模板与类的相互继承 */ 2 3 #include 4 5 using namespace std; 6 7 // 类继承与类模板:要求类模板实例化 8 9 // 类模板继承于类模板:要求类模板实例化 10 11 // 类模板继承于类:要求类模板实例化 12... 阅读全文

posted @ 2015-06-12 08:48 Dragon-wuxl 阅读(240) 评论(0) 推荐(0)

类模板当作函数的参数
摘要:1 /* 类模板当作函数的参数 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 template 9 void printandadd(array ar)// 有类模板参数的函数一定是函数模板10 {11 for(aut... 阅读全文

posted @ 2015-06-11 16:46 Dragon-wuxl 阅读(206) 评论(0) 推荐(0)

嵌套类与类模板的访问
摘要:1 /* 嵌套类与类模板的访问 */ 2 3 void main() 4 { 5 myclass *p = new myclass; 6 p->mynewclass;// 内部的类外部无法访问 7 8 myclass::mynewclass my1;// 第一种访问嵌套... 阅读全文

posted @ 2015-06-11 16:27 Dragon-wuxl 阅读(105) 评论(0) 推荐(0)

类与类模板的嵌套
摘要:1 /* 嵌套类 与 嵌套类模板 */ 2 3 #include 4 5 using namespace std; 6 7 // mynewclass 是 myclass 的嵌套类 8 // 嵌套类就是一个类的内部完全实现 9 // 允许无限嵌套 10 // 嵌套类与继承... 阅读全文

posted @ 2015-06-11 16:06 Dragon-wuxl 阅读(1159) 评论(0) 推荐(0)

类模板与函数模板包装器
摘要:函数包装器: 1 /* 函数包装器 */ 2 3 #include 4 5 using namespace std; 6 7 // T 代表任何数据 F代表任何操作(可以是函数,函数模板的一个实例化) 8 template 9 T run(T t,F f)10 {11 return... 阅读全文

posted @ 2015-06-11 15:06 Dragon-wuxl 阅读(288) 评论(0) 推荐(0)

数组模板
摘要:1 /* 数组模板 */ 2 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 using namespace std; 10 11 12 13 14 void main() 15 { 16 ... 阅读全文

posted @ 2015-06-11 10:25 Dragon-wuxl 阅读(122) 评论(0) 推荐(0)

模板类与类模板
摘要:1 /* 模板类与类模板 */ 2 3 #include 4 using namespace std; 5 6 7 // 类模板 8 template 9 class auto_point10 {11 public:12 T *p;// T是什么类型 p就是什么类型的指针13 ... 阅读全文

posted @ 2015-06-11 08:23 Dragon-wuxl 阅读(130) 评论(0) 推荐(0)

类模板
摘要:1 /* 类模板 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 template 9 class com10 {11 private:12 T a;13 T b;14 public:15 com(T ... 阅读全文

posted @ 2015-06-10 22:39 Dragon-wuxl 阅读(96) 评论(0) 推荐(0)

dynamic转换
摘要:1 /* dynamic转换 */ 2 3 #include 4 5 using namespace std; 6 7 class base 8 { 9 public:10 virtual void print()// 虚函数11 {12 cout (p)... 阅读全文

posted @ 2015-06-10 18:17 Dragon-wuxl 阅读(152) 评论(0) 推荐(0)

异质链表
摘要:1 /* 异质链表 */ 2 3 #include 4 #include 5 #include 6 using namespace std; 7 8 class base; 9 10 class linknode11 {12 public:13 base *p;14 linkn... 阅读全文

posted @ 2015-06-10 17:57 Dragon-wuxl 阅读(107) 评论(0) 推荐(0)

抽象类管理内存
摘要:1 /* 内存管理包含类的继承 */ 2 3 #include 4 #include 5 using namespace std; 6 7 vectormyv; 8 9 // 管理所有的内存地址 释放所有new 的个数10 class base11 {12 public:13 sta... 阅读全文

posted @ 2015-06-10 17:11 Dragon-wuxl 阅读(131) 评论(0) 推荐(0)

抽象类与纯虚函数
摘要:1 /* 抽象类与纯虚函数 */ 2 3 #include 4 5 using namespace std; 6 7 void show(myclassA my1)// 不行 副本机制会拷贝 拷贝会调用构造 8 { 9 10 }11 12 void show(myclassA & my1... 阅读全文

posted @ 2015-06-10 15:51 Dragon-wuxl 阅读(130) 评论(0) 推荐(0)

虚函数表
摘要:1 /* 虚函数原理 */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public: 10 virtual void go1() 11 { 12 cout <<... 阅读全文

posted @ 2015-06-10 15:09 Dragon-wuxl 阅读(137) 评论(0) 推荐(0)

虚函数sizeof以及简单虚函数表
摘要:1 /* cpp面试题 虚函数指针表的地址 */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public:10 virtual void run1()11 {12 cout <<... 阅读全文

posted @ 2015-06-10 10:42 Dragon-wuxl 阅读(135) 评论(0) 推荐(0)

虚函数重载以及虚函数特色必须this指针
摘要:1 /* 虚函数重载特色以及虚函数特点 */ 2 3 #include 4 5 using namespace std; 6 7 class A 8 { 9 public:10 // 虚函数靠this指针的转换来实现,必须是成员函数11 // 虚函数不可以是外部函数 不可以... 阅读全文

posted @ 2015-06-10 10:29 Dragon-wuxl 阅读(207) 评论(0) 推荐(0)

构造与析构函数是否可以是虚函数
摘要:1 /* 构造与析构的虚函数问题 */ 2 3 #include 4 5 using namespace std; 6 7 class ye 8 { 9 public:10 ye()// 禁止构造函数是虚函数11 {12 p1 = new char[1024*... 阅读全文

posted @ 2015-06-10 09:53 Dragon-wuxl 阅读(130) 评论(0) 推荐(0)

虚函数的本质就是指针类型转换实现的结果
摘要:1 /* 虚函数 */ 2 3 #include 4 5 using namespace std; 6 7 class A 8 { 9 public: 10 A(char x):x(x) 11 { 12 13 } 14 15 vo... 阅读全文

posted @ 2015-06-10 09:19 Dragon-wuxl 阅读(94) 评论(0) 推荐(0)

虚函数的意义
摘要:1 /* 虚函数的意义 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 9 class myinterface10 {11 public:12 virtual void server()13 {14 ... 阅读全文

posted @ 2015-06-09 23:31 Dragon-wuxl 阅读(143) 评论(0) 推荐(0)

父类与子类指针的问题
摘要:1 /* 父类与子类指针的问题 */ 2 3 4 #include 5 6 using namespace std; 7 8 class ye 9 { 10 public: 11 ye() 12 { 13 this->p = new int... 阅读全文

posted @ 2015-06-09 19:08 Dragon-wuxl 阅读(145) 评论(0) 推荐(0)

静态联编与动态联编重载与覆盖的区别
摘要:1 #include 2 3 using namespace std; 4 5 class A 6 { 7 public: 8 9 void print(int num)10 {11 cout << num << endl;12 }13 14 ... 阅读全文

posted @ 2015-06-09 15:50 Dragon-wuxl 阅读(258) 评论(0) 推荐(0)

多态
摘要:1 /* 多态 */ 2 3 #include 4 #include 5 6 using namespace std; 7 8 void print() 9 {10 printf("tasklist & pause");11 }12 13 void run()14 {15 s... 阅读全文

posted @ 2015-06-09 15:42 Dragon-wuxl 阅读(95) 评论(0) 推荐(0)

Qt演示多继承以及虚基类
摘要:1 #include "dialog.h" 2 #include 3 #include 4 5 6 7 //需要分别操作一个对象,不需要虚继承 8 //需要操作同一个,需要虚继承 9 //10 class DialogX //虚基类11 {12 protected:13 Di... 阅读全文

posted @ 2015-06-09 14:48 Dragon-wuxl 阅读(874) 评论(0) 推荐(0)

多继承以及虚基类
摘要:1 /* 多继承以及虚基类 */ 2 #include 3 4 using namespace std; 5 6 7 // 只有多继承 才产生虚基类 8 9 class base // 虚基类10 {11 public:12 base()13 {14 cou... 阅读全文

posted @ 2015-06-09 14:45 Dragon-wuxl 阅读(115) 评论(0) 推荐(0)

类的字节对齐
摘要:1 /* 继承中的类大小 */ 2 3 #include 4 5 using namespace std; 6 7 class A 8 { 9 int num;10 };11 12 class B : public A13 {14 double db;15 };16 17 c... 阅读全文

posted @ 2015-06-09 10:22 Dragon-wuxl 阅读(184) 评论(0) 推荐(0)

继承以及保护的案例
摘要:1 /* 继承以及保护的案例 */ 2 3 #include 4 5 using namespace std; 6 7 const double PI = 3.141592657; 8 9 // 点10 class point11 {12 public:13 14 poin... 阅读全文

posted @ 2015-06-09 09:42 Dragon-wuxl 阅读(107) 评论(0) 推荐(0)

Qt演示单继承传递参数
摘要:1 #include "mainwindow.h" 2 #include 3 #include 4 5 class ye 6 { 7 public: 8 ye(int a,int b):x(a),y(b) 9 {10 p= new MainWindow;11 ... 阅读全文

posted @ 2015-06-09 08:43 Dragon-wuxl 阅读(235) 评论(0) 推荐(0)

派生类访问基类静态函数
摘要:1 #include 2 3 using namespace std; 4 5 class base 6 { 7 public: 8 int num; 9 static int data;10 void print()11 {12 cout nu... 阅读全文

posted @ 2015-06-08 22:21 Dragon-wuxl 阅读(270) 评论(0) 推荐(0)

基类的静态成员
摘要:1 /* 基类的静态成员 */ 2 3 #include 4 5 using namespace std; 6 7 class base 8 { 9 public:10 static int num;11 12 base()13 {14 num+=1;... 阅读全文

posted @ 2015-06-08 22:00 Dragon-wuxl 阅读(390) 评论(0) 推荐(0)

继承构造析构顺序以及原理以及重名变量函数
摘要:1 /* 继承的内存原理 */ 2 3 /* 继承 */ 4 5 #include 6 7 using namespace std; 8 9 10 class ye 11 { 12 public: 13 int a = 11; 14 int b; 15 ... 阅读全文

posted @ 2015-06-08 21:31 Dragon-wuxl 阅读(164) 评论(0) 推荐(0)

自定义类类型之间互相转换
摘要:1 /* 自定义类类型之间互相转换 */ 2 3 #include 4 5 using namespace std; 6 7 // complex -> area 8 // area -> complex 9 10 class area11 {12 public:13 double ... 阅读全文

posted @ 2015-06-08 09:44 Dragon-wuxl 阅读(210) 评论(0) 推荐(0)

类型转换
摘要:1 /* 类型转换 */ 2 3 /* 转换方式 */ 4 5 #include 6 using namespace std; 7 8 int main() 9 { 10 int a = 3/2;// 隐式转换 11 12 double b = (int)... 阅读全文

posted @ 2015-06-07 09:55 Dragon-wuxl 阅读(72) 评论(0) 推荐(0)

为什么需要重载重载的简单实现
摘要:1 /* 运算符重载 */ 2 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 int main() 10 { 11 12 char *str1 = "abc"; 13 14 ... 阅读全文

posted @ 2015-06-07 09:04 Dragon-wuxl 阅读(190) 评论(0) 推荐(0)

友元类
摘要:1 /* 友元类 */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public:10 myclass(int a,int b):x(a),y(b)11 {12 13 }14 15 ... 阅读全文

posted @ 2015-06-06 16:56 Dragon-wuxl 阅读(86) 评论(0) 推荐(0)

友元函数
摘要:1 /* 友元函数 */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public:10 myclass(int a,int b):x(a),y(b)11 {12 13 }14 1... 阅读全文

posted @ 2015-06-06 16:10 Dragon-wuxl 阅读(96) 评论(0) 推荐(0)

静态成员函数
摘要:1 /* 静态成员函数 */ 2 3 #include 4 5 using namespace std 6 7 class myclass 8 { 9 public:10 myclass()11 {12 13 }14 15 ~myclass()16 {... 阅读全文

posted @ 2015-06-06 15:38 Dragon-wuxl 阅读(128) 评论(0) 推荐(0)

静态成员
摘要:1 /* 静态成员 */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public:10 static int num;11 12 int data;// 每一次都会重新创建13 14 ... 阅读全文

posted @ 2015-06-06 15:01 Dragon-wuxl 阅读(95) 评论(0) 推荐(0)

引用与类
摘要:1 /* 引用与类 */ 2 3 #include 4 5 using namespace std; 6 7 int g_num = 900; 8 9 10 // 引用只能初始化一次11 // 没有构造myclass():rnum(num),默认值会生效12 // 有构造 myclass(... 阅读全文

posted @ 2015-06-06 12:05 Dragon-wuxl 阅读(95) 评论(0) 推荐(0)

深浅拷贝以及拷贝构造应用于函数的参数返回值副本机制
摘要:1 #include 2 3 using namespace std; 4 5 class myclass 6 { 7 public: 8 9 myclass()10 {11 cout 50 #include51 52 using namespace ... 阅读全文

posted @ 2015-06-06 09:12 Dragon-wuxl 阅读(291) 评论(2) 推荐(0)

复制构造函数
摘要:1 /* 复制构造函数 */ 2 3 #include 4 5 using namespace std; 6 7 // 编译器会为任何一个类生成默认的构造和拷贝构造 8 // default保留 delete删除 9 class myclass10 {11 public:12 myc... 阅读全文

posted @ 2015-06-06 07:32 Dragon-wuxl 阅读(111) 评论(0) 推荐(0)

构造函数与析构函数
摘要:1 /* 构造函数与析构函数 */ 2 3 #include 4 5 // 所有的类 默认都有一个构造函数与析构函数 6 // 构造函数和析构函数可以重载,没有返回值 7 class myclass 8 { 9 public:10 int num;11 public:12 my... 阅读全文

posted @ 2015-06-04 14:43 Dragon-wuxl 阅读(133) 评论(0) 推荐(0)

mutable
摘要:1 /* mutable */ 2 3 #include 4 5 using namespace std; 6 7 class myclass 8 { 9 public:10 int num;11 // mutable 声明的变量 不受const 限制 可以在成员函数中修改12 ... 阅读全文

posted @ 2015-06-04 13:01 Dragon-wuxl 阅读(159) 评论(0) 推荐(0)

面向过程与面向对象的编程模式
摘要:C管理进程: 1 #define _CRT_SECURE_NO_WARNINGS 2 #include 3 #include 4 #include 5 6 //面向过程的模式 7 //代码重用主要靠函数 8 //权限, 9 10 void open(const char *path,const... 阅读全文

posted @ 2015-06-03 15:30 Dragon-wuxl 阅读(285) 评论(0) 推荐(0)

Cpp union
摘要:1 /* Cpp union */ 2 3 #include 4 5 // union 本质是一个类 可以内部有函数 6 // union 内部数据是共享的,不同对象之间是独立的 代码是共享的 7 // union 具备结构体所有的功能 8 // union 某些节约内存类 需要用到共用体 ... 阅读全文

posted @ 2015-06-03 10:12 Dragon-wuxl 阅读(219) 评论(0) 推荐(0)

递归汉诺塔
摘要:1 /* 递归汉诺塔 */ 2 3 #include 4 5 void han(int n,char A,char B,char C) 6 { 7 static int num = 1; 8 std::cout " >n;27 std::cout << "n = " <... 阅读全文

posted @ 2015-06-03 09:14 Dragon-wuxl 阅读(111) 评论(0) 推荐(0)

类的常识
摘要:1 /* 空类 */ 2 3 // 空类占一个字节 表明类存在 4 // 空类有int 占4个字节 5 // 空类代码不计入sizeof 6 class kong 7 { 8 public: 9 //int num;10 void go(int num)11 {12 ... 阅读全文

posted @ 2015-06-02 21:27 Dragon-wuxl 阅读(90) 评论(0) 推荐(0)

Cpp 结构体
摘要:1 /* Cpp 结构体 */ 2 3 #include 4 5 struct lstruct 6 { 7 int num; 8 }; 9 10 // c++ 结构体会给默认的值11 struct MyStruct12 {13 int num;14 double db ... 阅读全文

posted @ 2015-06-02 16:50 Dragon-wuxl 阅读(456) 评论(0) 推荐(0)

调试以及静态断言
摘要:/* 调试以及静态断言 */#include#include#includeusing namespace std;int main(){ int num = 100; cout = 4,"error"); } 阅读全文

posted @ 2015-06-02 15:18 Dragon-wuxl 阅读(113) 评论(0) 推荐(0)

CPP 多线程
摘要:1 /* CPP 多线程 */ 2 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 using namespace std::this_thread;10 11 void msg()12 {13 ... 阅读全文

posted @ 2015-06-02 14:50 Dragon-wuxl 阅读(243) 评论(0) 推荐(0)

智能指针
摘要:1 /* 智能指针 */ 2 3 #include 4 5 int main() 6 { 7 //auto_ptr; 8 9 for (int i=0;i autop(p);// 创建智能指针,管理指针p指向的内存15 }16 17 std::cin.... 阅读全文

posted @ 2015-06-02 12:36 Dragon-wuxl 阅读(99) 评论(0) 推荐(0)

模板元编程
摘要:1 /* 模板元编程 */ 2 3 // 模板元 就是把运行时消耗的时间在编译期间进行优化 4 5 #include 6 7 8 template 9 struct data10 {11 enum {res = data::res+data::res};12 13 };14 15... 阅读全文

posted @ 2015-06-02 12:14 Dragon-wuxl 阅读(165) 评论(0) 推荐(0)

using别名
摘要:1 /* using别名 */ 2 3 #include 4 5 namespace space // 隔离模板 避免冲突 6 { 7 8 template using ptr = T*;// 模板简写 9 10 }11 12 int add(int a,int b)13 {... 阅读全文

posted @ 2015-06-02 10:45 Dragon-wuxl 阅读(162) 评论(0) 推荐(0)

去掉转义
摘要:1 /* 去掉转义字符 */ 2 3 #include 4 #include 5 #include 6 7 int main() 8 { // R"()" 括号之间去掉转义字符 9 std::string path = R"("D:\Program Files (x86)\Ten... 阅读全文

posted @ 2015-06-02 10:10 Dragon-wuxl 阅读(162) 评论(0) 推荐(0)

仿函数
摘要:1 /* 内部函数绑定 */ 2 3 /* 引用内部函数绑定机制 */ 4 5 #include 6 #include// 处理函数 7 8 using namespace std; 9 using namespace std::placeholders;10 11 // 仿函数 :创建一个... 阅读全文

posted @ 2015-06-01 21:16 Dragon-wuxl 阅读(141) 评论(0) 推荐(0)

引用包装器
摘要:1 /* 引用包装器 */ 2 3 #include 4 5 template 6 void com(T arg)// 模板函数 引用无效 ,引用包装器有效 7 { 8 std::cout << "com= " << &arg << std::endl; 9 arg++;1... 阅读全文

posted @ 2015-06-01 20:46 Dragon-wuxl 阅读(124) 评论(0) 推荐(0)

模板的重载
摘要:1 /* 模板的重载 */ 2 3 #include 4 #include 5 using std::array; 6 7 template 8 void showarray(array myarray,int n) 9 {10 using namespace std;11 c... 阅读全文

posted @ 2015-06-01 14:50 Dragon-wuxl 阅读(152) 评论(0) 推荐(0)

new 高级用法
摘要:1 /* new 高级用法 */ 2 3 #include 4 #include 5 6 const int buf(512);// 限定一个常量整数 7 int N(5);// 数组的长度 8 char buffer[buf] = {0};// 静态区 9 10 using namespa... 阅读全文

posted @ 2015-06-01 14:24 Dragon-wuxl 阅读(197) 评论(0) 推荐(0)

多元数组
摘要:1 /* 多元数组 */ 2 3 #include 4 #include 5 6 void main() 7 { 8 int int1 = 10; 9 double double1 = 99.8;10 char ch = 'A';11 char *str = "... 阅读全文

posted @ 2015-06-01 11:29 Dragon-wuxl 阅读(188) 评论(0) 推荐(0)

vector 增删查改及可变数组
摘要:1 /* vector 增删查改 */ 2 #include 3 #include 4 #include 5 6 void main() 7 { 8 std::vector myvector(5);// 分配5个空间,默认初始化为0 9 myvector.push_back(1)... 阅读全文

posted @ 2015-06-01 10:33 Dragon-wuxl 阅读(276) 评论(0) 推荐(0)

lambda表达式
摘要:1 #include 2 #include 3 #include// 算法头文件 lambda表达式 array vector 实用 4 5 6 void main() 7 { 8 std::vector myvector; 9 myvector.push_back(11);... 阅读全文

posted @ 2015-06-01 09:33 Dragon-wuxl 阅读(161) 评论(0) 推荐(0)

导航