Why are pointers not needed for structures and primitve types? [closed]
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.
精彩评论