开发者

In obj-c, do i have to initialise values eg pointers, or are they auto initialised to nil?

In obj-c, do i have to initialise values eg pointers, or are they auto 开发者_Python百科initialised to nil?

Eg:

- (void) myfunc {
    EpgSparseEntry *onNow=nil, *next=nil, *later=nil;
}

Do i need the =nil , or can i assume that variables on the stack are initialised to zero/nil?

Thanks


Can i assume that variables on the stack are initialised to zero/nil?

No. Variables on the stack are not initialized so they contain random data.

That's different from an object's instance variables because all the memory an object occupies is zeroed out upon allocation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜