码迷,mamicode.com
首页 >  
搜索关键字:ptr    ( 2121个结果
C语言基础知识----指针数组 && 数组指针 && 函数指针 &&指针函数
指针数组 && 数组指针 char (*ptr)[5]; //定义一个指向数组指针ptr,指向包含5个char类型的数组 char *a[5]; //定义一个指针数组a,包含5个char*类型指针 #include int main(void) {     char *a[5]={"red","white","blue","dark","green"};     pri...
分类:编程语言   时间:2014-08-19 12:55:44    阅读次数:230
linux 下getch()函数实现
//调用 //char*ptr=(char*)malloc(sizeof(char)*128); //ptr=get_passwd(); //printf("\n");#include<stdio.h>#include<termios.h>#include<unistd.h>#include<assert.h>#include<string.h>#include<stdlib.h>intgetch(){ intc=0; structt..
分类:系统相关   时间:2014-08-15 02:42:17    阅读次数:300
CvMat的初始化,读取和修改
程序:代码:#include"cv.h" #include"cxcore.h" #include"highgui.h" #include<iostream> floatMatSum(CvMat*mat)//读取CvMat的恰当方法 { floatsum=0; for(introws=0;rows<mat->rows;rows++) { constfloat*data=(constfloat*)(mat->data.ptr+rows*mat->ste..
分类:其他好文   时间:2014-08-14 21:03:39    阅读次数:223
学习笔记:shared_ptr陷阱
条款1:不要把一个原生指针给多个shared_ptr管理int* ptr = new int;shared_ptr p1(ptr);shared_ptr p2(ptr); //logic errorptr对象被删除了2次这种问题比喻成“二龙治水”,在原生指针中也同样可能发生。条款2:不要把this指...
分类:其他好文   时间:2014-08-14 01:16:47    阅读次数:286
boost::share_ptr用法
boost中提供了几种智能指针方法:scoped_ptr shared_ptr intrusive_ptr weak_ptr,而标准库中提供的智能指针为auto_ptr.这其中,我最喜欢,使用最多的是shared_ptr,也最让人随心所欲.使用很简单,如下:头文件 class A{virtual v...
分类:其他好文   时间:2014-08-14 01:16:37    阅读次数:243
auto_ptr,shared_ptr 智能指针的使用
Q: 那个auto_ptr是什么东东啊?为什么没有auto_array?A: 哦,auto_ptr是一个很简单的资源封装类,是在头文件中定义的。它使用“资源分配即初始化”技术来保证资源在发生异常时也能被安全释放(“exception safety”)。一个auto_ptr封装了一个指针,也可以被当作...
分类:其他好文   时间:2014-08-14 01:12:07    阅读次数:340
整型变量(int)与字节数组(byte[])的相互转换
//?int2byte.cpp?:?定义控制台应用程序的入口点。 // #include?"stdafx.h" #include?<Windows.h> /* #define?MAKEWORD(a,?b) ((WORD)(((BYTE)(((DWORD_PTR)(a)) & 0xff))?|?((WORD)((BYTE)(...
分类:其他好文   时间:2014-08-12 22:20:58    阅读次数:417
Windows Server 2012 R2 DNS配置
DNS配置打开“网络和共享中心”在安装完域控制器后,DNS地址已转变为指向本地的127.0.0.1,可以更改为本机IP192.168.0.22.在ServerManager中打开Tools内的DNS组件3.正向查找区域如下图所示4.在ReverseLookupZones新建区域5.新建“反向查找区域向导”6.这里有三种区域类型:1)..
分类:Windows程序   时间:2014-08-12 03:39:24    阅读次数:1655
boost中asio网络库多线程并发处理实现,以及asio在多线程模型中线程的调度情况和线程安全。
1、实现多线程方法:其实就是多个线程同时调用io_service::run for (int i = 0; i != m_nThreads; ++i) { boost::shared_ptr pTh(new boost::thread( boost::bind(&...
分类:编程语言   时间:2014-08-12 00:34:33    阅读次数:1592
boost 学习
智能指针的学习中文教程网站http://zh.highscore.de/cpp/boost/不过代码可能 由于BOOST 版本不同需要稍作修改scoped_ptr 离开作用域则自动调用类析构函数或者函数delete方法shared_ptr 使用率最高的指针 类似scoped_ptr 但是所有权可以转...
分类:其他好文   时间:2014-08-11 20:48:02    阅读次数:270
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!