nullptr是c++11中的关键字,表示空指针 要区分nullptr和NULL,首先要明白NULL的含义: NULL是一个宏定义,在c和c++中的定义不同,c中NULL为(void*)0,而c++中NULL为整数0 所以在c++中int *p=NULL; 实际表示将指针P的值赋为0,而c++中当一 ...
分类:
其他好文 时间:
2016-05-19 23:22:16
阅读次数:
374
这题有点繁琐,在更新指针时很容易出错。 ListNode *reverseKGroup(ListNode *head, int k) { if (head == nullptr || head->next == nullptr || k < 2)return head; ListNode dummy ...
分类:
其他好文 时间:
2016-05-19 16:21:34
阅读次数:
120
很简单的一题,需要注意的是如果某结点重复了记得将其删除。 ListNode *deleteDuplicates(ListNode *head) { if (head == nullptr) return nullptr; ListNode *prev = head; for (ListNode *c ...
分类:
其他好文 时间:
2016-05-18 16:11:40
阅读次数:
146
最近遇到的问题,具体如下:
#include
using namespace std;
typedef void(*P[10])(bool& flag);
#define N 10000
#define M 10000
template
void fun(bool& flag)
{
int i;
static T** p=nullptr;
switch (flag)
{
case ...
分类:
编程语言 时间:
2016-05-07 09:12:51
阅读次数:
178
在C++中指针是经常用到的,但是在使用指针的时候,程序员一定要非常注意,不然很容易就造成系统崩溃或者大量的资源浪费,这里就介绍几种指针的概念。 空指针:就是初始化为0、null或者nullptr的指针。在以前一般都是使用的Null来让该指针成为空指针,在最新版本的C++11中我们可以给指针赋值为nu ...
分类:
其他好文 时间:
2016-05-05 12:28:37
阅读次数:
149
C++11 中, nullptr 是空指针,可用来给 (指向任意对象类型的) 指针进行赋值 广义整型 (integral types) = char, short, int, long, long longnd and their unsigned counterparts, and bool, w ...
分类:
编程语言 时间:
2016-05-04 22:52:08
阅读次数:
252
这个例子是初始化LibOVR和请求关于有效HMD的信息。
回顾下面的代码:
// Include the OculusVR SDK
#include
void Application()
{
ovrResult result = ovr_Initialize(nullptr);
if (OVR_FAILURE(result))
return;...
分类:
其他好文 时间:
2016-04-29 19:14:49
阅读次数:
388
auto,decltype,for,nullptr如果编译器在定义一个变量的时候可以推断出变量的类型,不用写变量的类型,你只需写auto即可auto str = "sissie";
assert(typeid(str) == typeid(const char *));auto处理引用时默认是值类型,可以指定&作为修饰符强制它作为引用,auto自动获取指针类型,也可以显示地指定指针类型int& fo...
分类:
编程语言 时间:
2016-04-29 17:25:00
阅读次数:
307
这个例子是初始化LibOVR和请求关于有效HMD的信息。
回顾下面的代码:
// Include the OculusVR SDK
#include
void Application()
{
ovrResult result = ovr_Initialize(nullptr);
if (OVR_FAILURE(result))
return;...
分类:
其他好文 时间:
2016-04-26 21:21:45
阅读次数:
250
auto,decltype,for,nullptr如果编译器在定义一个变量的时候可以推断出变量的类型,不用写变量的类型,你只需写auto即可auto str = "sissie";
assert(typeid(str) == typeid(const char *));auto处理引用时默认是值类型,可以指定&作为修饰符强制它作为引用,auto自动获取指针类型,也可以显示地指定指针类型int& fo...
分类:
编程语言 时间:
2016-04-26 19:47:26
阅读次数:
249