码迷,mamicode.com
首页 >  
搜索关键字:ptr    ( 2121个结果
C++11笔记1
目录:1.std::share_ptr智能指针:2.std::tr1::function模板类:3.stringstream:4.set/vector/map:5.static_cast (expression);std::share_ptr智能指针:http://en.cppreference.c...
分类:编程语言   时间:2015-12-27 17:41:57    阅读次数:292
数组小记 &数组名+1
昨晚有小伙伴问了一道题,感觉挺经典的。 1 int a[5] = {1, 2, 3, 4, 5};2 3 int *ptr = (int *) (&a + 1);4 5 printf("%d %d \n\r", *(a + 1), *(ptr - 1) );从内存分布的角度来解析:&a和a做右值时....
分类:编程语言   时间:2015-12-27 13:25:48    阅读次数:298
检查内存泄漏
1.分配空间2.记录内存块信息3.调用构造函数(类型萃取)#include<iostream> #include<string> #include<list> #include<assert.h> usingnamespacestd; structBlockInfo { void*_ptr; string_file; int_line; BlockInfo(void*ptr,constchar*file,in..
分类:其他好文   时间:2015-12-26 23:52:18    阅读次数:387
实战c++中的智能指针unique_ptr系列-- unique_ptr的get_deleter方法(自定义删除器)
unique_ptr的成员函数在上一篇博客中几乎全部涵盖,其实还有一个很有踢掉,即std::unique_ptr::get_deleter字面已经很明显了,就获得deleter: Returns the stored deleterThe stored deleter is a callable object. A functional call to this object with a sin...
分类:编程语言   时间:2015-12-26 13:29:22    阅读次数:491
实战c++中的智能指针unique_ptr系列-- unique_ptr的operator=、operator bool、reset、swap、get等介绍
既然打算把unique_ptr写一个系列,就要详尽一点,有些内容也许在vector的时候有个涉及,但是现在还是再谈论一番。我们要把unique_ptr看做一个类,废话了,它当然是一个类。所以这个类肯定也重载了赋值运算符,即operator=。现在就开始看看operator=在unique_ptr中的使用: 官方描述如下:move assignment (1) unique_ptr& operat...
分类:编程语言   时间:2015-12-26 01:15:51    阅读次数:254
C++里面定时器的使用
说白了就是三个函数的使用:SetTimer(20, 20, 0); //第一个20表示此定时器的标识符,第二个20表示你要定的时间,第三个不用管,设0即可。void CLMS511_interfaceDlg::OnTimer(UINT_PTR nIDEvent){ // TODO: Add your...
分类:编程语言   时间:2015-12-25 08:48:21    阅读次数:368
实战c++中的智能指针unique_ptr系列-- 使用std::unique_ptr代替new operator(错误:‘unique_ptr’ is not a member of ‘std’)
写了很多篇关于vector的博客,其实vector很便捷,也很简单。但是很多易错的问题都是vector中的元素为智能指针所引起的。所以决定开始写一写关于智能指针的故事,尤其是unique_ptr指针的故事。这是个开始,就让我们使用std::unique_ptr代替new operator吧!还是用程序说话:#include int main() { while (true...
分类:编程语言   时间:2015-12-24 23:56:43    阅读次数:432
实战c++中的vector系列--使用sort算法对vector<unique_ptr<string>>进行排序(sort函数出错“应输入 2 个参数,却提供了 3 个)
之前博客写了对vector使用sort算法进行的排序,之前也写到过vector<unique_ptr>的一些处理方法。今天就写一下对vector<unique_ptr>使用sort算法进行排序。#include #include #include #include #include<memory...
分类:编程语言   时间:2015-12-23 21:27:01    阅读次数:352
中序线索二叉树创建及其遍历
通过考察各种二叉链表,不管儿叉树的形态如何,空链域的个数总是多过非空链域的个数。准确的说,n各结点的二叉链表共有2n个链域,非空链域为n-1个,但其中的空链域却有n+1个。如下图所示。 因此,提出了一种方法,利用原来的空链域存放指针,指向树中其他结点。这种指针称为线索。 记ptr指向二叉链表中...
分类:其他好文   时间:2015-12-23 12:27:02    阅读次数:192
c++ 浅谈 new 的使用
实例用法: 创建对象: class U_Ptr smart; U_Ptr* ptr = new U_Ptr(); class U_Ptr smart(new U_Ptr(p)); int *p = new int; //此时指针p指向一个int对象,该对象没有被初始化 int...
分类:编程语言   时间:2015-12-23 12:22:33    阅读次数:306
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!