开发者

Why are pointers not needed for structures and primitve types? [closed]

开发者 https://www.devze.com 2023-04-07 02:47 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, o开发者_JAVA技巧verly broad, or rhetorical andcannot be reasonably answered in its current form.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, o开发者_JAVA技巧verly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

On C and Objective-C, why aren't pointers needed for structures and primite types?


Primitive types can be on the stack (no pointer) or on the heap (pointer), Obj-C objects can only be on the heap (pointer).

In some languages such as C++ objects can be on either the stack or heap. In yet other languages all objects are on the heap and no pointer (*) character is required.

There is a minor exceptions for blocks in Obj-C in that they can be on either the stack or heap.


Because that is the nature of those objects.

structs and arrays, in most ways are pointers to memory configured in the order you describe when you define the struct or array.

primitive types just hunks of memory big enough to store the type of information you request.

Obj-c objects are pointers because you only get their address and then send them messages.

0

精彩评论

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