码迷,mamicode.com
首页 >  
搜索关键字:pointer    ( 2176个结果
[LeetCode]Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 利用hashMap存储,原始的node作为key,new的nod...
分类:其他好文   时间:2014-12-24 22:53:14    阅读次数:187
智能指针的实现--使用引用计数实现以及原理
一、智能指针   在C++语言编程时,当类中有指针成员时,一般有两种方式来管理指针成员:一是采用值型的方式管理,每个类对象都保留一份指针指向的对象的拷贝;另一种更优雅的方式是使用智能指针,从而实现指针指向的对象的共享。       智能指针(smart pointer)的一种通用实现技术是使用引用计数(reference count)。智能指针类将一个计数器与类指向的对象相关联,引用计数跟踪该...
分类:其他好文   时间:2014-12-24 22:45:20    阅读次数:161
[LeetCode]116.Populating Next Right Pointers in Each Node
【题目】 Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its nex...
分类:其他好文   时间:2014-12-24 20:13:35    阅读次数:151
二、关键词 之 指针数组和数组指针的区别
这两个名字不同当然所代表的意思也就不同。我刚开始看到这就吓到了,主要是中文太博大精深了,整这样的简称太专业了,把人都绕晕了。从英文解释或中文全称看就比较容易理解。指针数组:array of pointers,即用于存储指针的数组,也就是数组元素都是指针数组指针:a pointer to an arr...
分类:编程语言   时间:2014-12-21 17:49:19    阅读次数:252
C++智能指针的设计和使用
对于一个C++的使用者来说,指针的使用可以算的上是家常便饭,但是在使用的过程中,很多时候可能会因为new或者malloc了一个对象,而忘记最后结束的时候去释放掉(我就会犯这样子的错误),从而导致内存泄露。而此时智能指针可能可以帮助我去解决这个问题。 智能指针(smart pointer)是利用个引用计数的策略去处理指针的释放,从而保证指针的安全性。通常情况下,我们会自己去设计一个智能指针类去管理...
分类:编程语言   时间:2014-12-21 16:40:36    阅读次数:227
Visitor
#include #include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Element;class Visitor{public: virtual ...
分类:其他好文   时间:2014-12-18 18:18:30    阅读次数:186
[002]初识指针
指针(pointer)与引用都实现了对其它对象的间接访问,但与引用不同的是,指针本身是一个对象,也无须在定义时赋初值。用*p的形式来定义指针。1 int val, *p2; //val是int类型对象,p2是指向int对象的指针由于指针存放的是对象的地址,所以要想获取该地址,需要使用取...
分类:其他好文   时间:2014-12-17 22:20:53    阅读次数:166
Command
#include using namespace std;#define DESTROY_POINTER(ptr) if (ptr) { delete ptr; ptr = NULL; }class Receiver{public: void Action1() { coutAction1()...
分类:其他好文   时间:2014-12-17 12:41:41    阅读次数:126
C++:不同类型的指针的本质与差异
转自:http://blog.csdn.net/richerg85/article/details/10076365 指针的类型(The Type of a Pointer) 一个指向ZooAnimal(一个类)的指针是如何与一个指向整型的指针或者指向template Array的指针有所不同? Z...
分类:编程语言   时间:2014-12-17 12:17:55    阅读次数:256
Lowest Common Ancestor of a Binary Tree, with Parent Pointer
Given a binary tree, find the lowest common ancestor of two given nodes in tree. Each node contains a parent pointer which links to its parent.int get...
分类:其他好文   时间:2014-12-17 01:28:42    阅读次数:152
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!