如何在c ++中初始化指针, [英] How to initialize a pointer in c++,

查看:79
本文介绍了如何在c ++中初始化指针,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c ++中初始化指针,

大多数情况下,我使用null,例如,

char * szName = null;

但是,如果我编译它而不包括afxdisp.h

,.net编译器告诉我标识符没有声明。


但是如果我基于lunix操作系统,也是正确的。


我认为我应该使用0,例如,

char * szName = 0;

是否更通用?


感谢先进

解决方案

?μ· é£?写道:

如何在c ++中初始化指针,
大多数情况下,我使用null,例如,
char * szName = null;
但是,如果我编译它不包括afxdisp.h
,。net编译器告诉我标识符没有声明。



不是标准的标题。


使用NULL。


-

Ian Collins。


Ian Collins写道:< blockquote class =post_quotes>?μ·é£?写道:

如何在c ++中初始化指针,
大多数情况下,我使用null,例如,
char * szName = null;
但是,如果我编译它不包括afxdisp.h
,。net编译器告诉我标识符没有声明。


不是标准的标题。

使用NULL 。




或者只是0.

Jonathan


Ian柯林斯写道:

?μ·é£?写道:

如何在c ++中初始化指针,
大多数情况下,我使用null,例如,
char * szName = null;
但是,如果我编译它不包括afxdisp.h
,。net编译器告诉我标识符没有声明。


不是标准的标题。

使用NULL。




默认情况下没有定义NULL。


Ben


How to initialize a pointer in c++,
Mostly, I use null, for example,
char * szName = null;
However, if i compile it without including afxdisp.h
, .net compiler tell me that the identifier is not declared.

but if i base on lunix operate system, is it correct also.

I think i shoud use 0, for example,
char * szName =0;
is it more general?

thank in advanced

解决方案

?μ·é£? wrote:

How to initialize a pointer in c++,
Mostly, I use null, for example,
char * szName = null;
However, if i compile it without including afxdisp.h
, .net compiler tell me that the identifier is not declared.


Not a standard header.

Use NULL.

--
Ian Collins.


Ian Collins wrote:

?μ·é£? wrote:

How to initialize a pointer in c++,
Mostly, I use null, for example,
char * szName = null;
However, if i compile it without including afxdisp.h
, .net compiler tell me that the identifier is not declared.


Not a standard header.

Use NULL.



Or just 0.
Jonathan


Ian Collins wrote:

?μ·é£? wrote:

How to initialize a pointer in c++,
Mostly, I use null, for example,
char * szName = null;
However, if i compile it without including afxdisp.h
, .net compiler tell me that the identifier is not declared.


Not a standard header.

Use NULL.



NULL is not defined by default.

Ben


这篇关于如何在c ++中初始化指针,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆