I know a contiguous block of memory is allocated for an array.
My first question is when the array element is an object rather than a built-in type, what gets stored in the contiguous memory reserved for the array? Pointer for the object or the actual data for the object? My guess is pointers are stored in the array and the actual objects are stored randomly in the heap. Am I correct?
My second question is now we want to reserve a specified memory(e.g., shared memory) for an array of objects. What is the best way to achieve this? Should I serialise the actual objects in the specified memory one by one and use relative pointers(e.g., indices) to access each of them?