2016年12月26日

拷贝控制和引用计数

摘要: #includeusing std::endl;using std::cin;using std::cout;#include using std::string;struct HasPtr_value{ //new 返回一个指向对象的指针 HasPtr_value(stri... 阅读全文

posted @ 2016-12-26 23:47 雪峰00 阅读(76) 评论(0) 推荐(0)

2016年12月13日

数组在表达式中解释为指针的规则受抑制的三种情况

摘要: 总结来于《征服C指针》,前桥和弥#includeusing std::cin;using std::cout;using std::endl;int main(){ //..以下三种情况 数组在表达式中解释为指向其第一个元素的指针的规则受到抑制 int a... 阅读全文

posted @ 2016-12-13 22:49 雪峰00 阅读(108) 评论(0) 推荐(0)

2016年9月17日

征服c指针笔记

摘要: #includeusing std::cin;using std::cout;using std::endl;void Func_1(int i){ cout<<i<<endl;}int main(){ /*int a[3]; int *pa=a; int (*parray)... 阅读全文

posted @ 2016-09-17 10:49 雪峰00 阅读(100) 评论(0) 推荐(0)

2016年9月11日

c++可变长参数的函数

摘要: #include #include #include #include int tiny_sum(int i,...){ int j=i; va_list ap; va_start(ap,i);//将ap指向参数i后面的参数,也就是说第一个参数会被跳过。 whi... 阅读全文

posted @ 2016-09-11 15:28 雪峰00 阅读(615) 评论(0) 推荐(0)

2016年8月14日

优先队列(非模板函数,是int)

摘要: 发现了一个可能是书里的错误,在swim函数中while检测的条件void priorityQueue::Swim(size_t t){ inArr[0]=inArr[t]; while (inArr[t/2]#ifndef LUPRIORITY_QUEUE#define ... 阅读全文

posted @ 2016-08-14 16:12 雪峰00 阅读(112) 评论(0) 推荐(0)

2016年7月24日

队列简要实现,是queue,不是dequeue

摘要: #ifndef MYQUEUE_H#define MYQUEUE_Hstruct Node{ int data; Node *next;};class LUqueue{public: LUqueue(); ~LUqueue(); void Push(int data); in... 阅读全文

posted @ 2016-07-24 21:09 雪峰00 阅读(141) 评论(0) 推荐(0)

栈实现,不是用template做的.

摘要: 用单链表来实现栈,插入和删除的部分很有意思。写完这个感觉突然理解了书上说的适配器的观点,类就是这样,不管你底层实现是什么,表现成什么就好了,是一个黑盒。头文件Mystack.h#ifndef MYSATCK_H#define MYSTACK_Hstruct Node { in... 阅读全文

posted @ 2016-07-24 20:33 雪峰00 阅读(87) 评论(0) 推荐(0)

2016年7月13日

杨辉三角,一个vector实现,不复制,不用队列。

摘要: 昨晚写到纸上,今天晚上调通,本来想要动态数组,但是发现这块的知识还欠缺,用着有问题。自己基础知识一直有问题,真是心急,要学习的知识好多,都不知道先学哪个。整个代码效率应该很低,因为进行了大量的判断。目前没有在网上搜到一样的代码,有点小虚荣。#include#include u... 阅读全文

posted @ 2016-07-13 23:22 雪峰00 阅读(141) 评论(0) 推荐(0)

2016年6月9日

多维数组与指针

摘要: 今天在写遍历二维数组的时候,突然思考这个问题,原因在于作内层循环时,对指针和数组理解不到位。虽然一直都会也写遍历二维数组,但是原先从没有想过这个问题。(逃)头文件#ifndef TREBLE_H#define TREBLE_H#includetypedef int int_a... 阅读全文

posted @ 2016-06-09 18:17 雪峰00 阅读(125) 评论(0) 推荐(0)

2016年5月31日

三种方法检测数组边界

摘要: c++primer里的一道题int *a;int a[];int a[10];三种形参都一样,都被认为是int *a。能检测边界的只有这种 int(&a)[10]。#includeusing std::cin;using std::cout;using std::endl;i... 阅读全文

posted @ 2016-05-31 20:54 雪峰00 阅读(519) 评论(0) 推荐(0)

导航