Home > Enterprise >  Order of memory locations
Order of memory locations

Time:01-20

What is the order of memory locations allocated by new operator?

For the context, if we are implementing a linked list, then does the new nodes created successively have increasing memory locations?

CodePudding user response:

What is the order of memory locations allocated by new operator?

The order is unspecified by the language. The order is what-ever the language implementation chooses it to be.

if we are implementing a linked list, then does the new nodes created successively have increasing memory locations?

If you use the default allocator, then they could have; but they might not have. And if they do have, that may be incidental. There are no guarantees either way.

If you write an allocator of your own, then you are in control of the allocations.

  •  Tags:  
  • Related