Perils of Constructors
I don&#x27;t have a CS background, so apologies in advance if these are basic questions, but:<p>&gt; For this layout to work though, constructor needs to allocate memory for the whole object at once. It can’t allocate just enough space for base, and than append derived fields afterwards. But such piece-wise allocation is required if we want a record syntax were we can just specify a value for a base class.<p>1. Why can the constructor not allocate memory &quot;progressively&quot; for the object as the construction chain descends the class hierarchy? Is it because, in a multi-threaded program, something else might allocate some of the &quot;extended&quot; memory, causing a clash when the constructor attempts to append fields? I assume that an approach of &quot;if the memory that a constructor is trying to append into is already allocated, first move the occupying object to a free memory location, and then continue with allocation&quot; is inefficient because it relies on an &quot;overseer&quot; that can coordinate and resolve these clashes?<p>1a. Sub-question - why does the memory for an object need to be contiguous? Is this purely an efficiency concern (&quot;read a whole object sequentially&quot; being more efficient than &quot;read an object by reading a bunch of pointers and then reading the locations they point to&quot;), or are there other considerations? I was under the impression that RAM (unlike hard drives) has no (or, negligible) performance penalty to random access - but maybe those intermediate &quot;jumps&quot; add up to a measurable impact?<p>2. &quot;But such piece-wise allocation is required if we want a record syntax were we can just specify a value for a base class.&quot; I don&#x27;t understand this claim at all. Why is this required? What does it mean to &quot;specify a value for a base class&quot; - is this shorthand for &quot;specify a value for a field of a base class&quot;?<p>Recommendations for further reading are received just as gratefully as direct explanations - I&#x27;m sure these concepts are already covered in the literature or a course syllabus, but I have no idea where to start!