Inheritance from the compiler perspective

We can picture the Rectangle class we declared earlier in the following way:

When we declare the rect object in the main() function, the space that's required for the local objects of the function is allocated in the stack. The same logic follows for the make_big_rectangle() function when it's called. It doesn't have local arguments; instead, it has an argument of the Rectangle& type, which behaves in a similar fashion to a pointer: it takes the memory space required to store a memory address (4 or 8 bytes in 32- and 64-bit systems, respectively). The rect object is passed to make_big_rectangle()

Get Expert C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.