一般情况下,我们使用#define来定义一个常量,#define的本质是文本替换,例如#define INT_PTR int*,这时候我们使用INT_PTR,INT_PTR a,b;这条语句等价于int * a,b;也就是定义了一个指针变量a和整型变量b,这是#define常用的场景和需要注意的细节...
分类:
其他好文 时间:
2015-06-21 01:59:31
阅读次数:
101
节选自《C语言深度剖析》首先看个例子main(){ int a[5]={1,2,3,4,5}; int *ptr=(int *)(&a+1); printf("%d,%d",*(a+1),*(ptr-1)); // 2 5}&a: 取数组a的首地址,&a之后+1,是加一个数组的长度...
分类:
编程语言 时间:
2015-06-21 00:44:12
阅读次数:
159
#include
using namespace std;template
class auto_ptr_
{
public:
auto_ptr_(Type *t = NULL) :ptr(t), count(new int(1))
{
}
auto_ptr_(const auto_ptr_& at) :ptr(at...
分类:
编程语言 时间:
2015-06-20 18:27:19
阅读次数:
149
#include
using namespace std;template//引用计数的只能指针
class auto_ptr_
{
public:
auto_ptr_(Type *t = NULL):ptr(t), count(1)
{
}
auto_ptr_(const auto_ptr_& at)...
分类:
编程语言 时间:
2015-06-20 09:12:08
阅读次数:
136
// 由一组点集生成一张三角面片网格Geometry osg::Geometry* createTRIANGLESGeometry(MyMesh &mesh) { osg::ref_ptr triGeom = new osg::Geometry(); ...
分类:
其他好文 时间:
2015-06-19 10:11:14
阅读次数:
169
Keyword Typename1 template2 class SomeClass3 {4 typename T::subtype * ptr;5 };如果没有typename,T::subtype会被认为是一个静态成员。A practical example: 1 // print e...
分类:
编程语言 时间:
2015-06-18 23:47:36
阅读次数:
172
Unique pointer:
Manages the storage of a pointer, providing a limited garbage-collection facility, with little to no overhead over built-in pointers (depending on the deleter used).
These obje...
分类:
其他好文 时间:
2015-06-18 22:20:18
阅读次数:
182
类的具体实现如下:
/////////////////////////
#include"LinearList.h"
#include
#include
using namespace std;
template
struct LinkNode //链表节点类
{
T data;
LinkNode* link;
LinkNode(LinkNode* ptr...
分类:
其他好文 时间:
2015-06-18 15:29:01
阅读次数:
151
智能指针解决了资源生存期管理的问题(尤其是动态分配的对象)。智能指针有各种不同的风格。多数都有一种共同的关键特性:自动资源管理。这种特性可能以不同的方式出现:如动态分配对象的生存期控制,和获取及释放资源 (文件, 网络连接)。这里主要讨论第一种情况,它们保存指向动态分配对象的指针,并在正确的时候删除这些对象。 何时我们需要智能指针?
有三种典型的情况适合使用智能指针:
? 资源所有权的...
分类:
其他好文 时间:
2015-06-18 11:35:53
阅读次数:
197
import maya.OpenMayaUI as omui import maya.cmds as cmds from shiboken import wrapInstance ptr = omui.MQtUtil.findControl(cmds.channelBox()) channelBox_widget = wrapInstance(long(ptr), QtGui.QWidget...
分类:
其他好文 时间:
2015-06-17 20:10:50
阅读次数:
194