The superhero struct wonderwoman int isis superhero superman
![The superhero struct wonderwoman (int) isis (superhero *) superman (int *[]) I use short The superhero struct wonderwoman (int) isis (superhero *) superman (int *[]) I use short](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-1.jpg)
![superhero marineboy[2]; superhero marineboy[2];](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-2.jpg)
![superhero marineboy[2]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy superhero marineboy[2]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-3.jpg)
![superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-4.jpg)
![superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-5.jpg)
![ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-6.jpg)
![ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-7.jpg)
![marineboy[0]. wonderwoman = 152; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman marineboy[0]. wonderwoman = 152; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-8.jpg)
![marineboy[0]. wonderwoman = 152; 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy marineboy[0]. wonderwoman = 152; 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-9.jpg)
![marineboy[0]. superman[0] = new int[2]; 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy[0]. superman[0] = new int[2]; 152 wonderwoman (int) isis (superhero *) superman (int *[])](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-10.jpg)
![marineboy[0]. superman[0] = new int[2]; heap stack 152 wonderwoman (int) isis (superhero *) superman marineboy[0]. superman[0] = new int[2]; heap stack 152 wonderwoman (int) isis (superhero *) superman](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-11.jpg)
![marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-12.jpg)
![marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-13.jpg)
![marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-14.jpg)
![marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-15.jpg)
![ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-16.jpg)
![ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-17.jpg)
![ironman->superman[1] = &(marineboy[0]. superman[0][1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int ironman->superman[1] = &(marineboy[0]. superman[0][1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-18.jpg)
![ironman->superman[1] = &(marineboy[0]. superman[0][1]); heap stack 152 wonderwoman (int) isis (superhero *) superman (int ironman->superman[1] = &(marineboy[0]. superman[0][1]); heap stack 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-19.jpg)
![*(ironman->superman[1]) = 9189; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) *(ironman->superman[1]) = 9189; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[])](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-20.jpg)
![*(ironman->superman[1]) = 9189; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *(ironman->superman[1]) = 9189; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-21.jpg)
![marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-22.jpg)
![marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-23.jpg)
![marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-24.jpg)
![marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-25.jpg)

![In Barbarella: heap elektra() stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) In Barbarella: heap elektra() stack 152 wonderwoman (int) isis (superhero *) superman (int *[])](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-27.jpg)
![barbarella(marineboy[1], ironman->isis); heap elektra() stack 9189 152 wonderwoman (int) isis (superhero *) superman (int barbarella(marineboy[1], ironman->isis); heap elektra() stack 9189 152 wonderwoman (int) isis (superhero *) superman (int](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-28.jpg)







![catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-36.jpg)
![catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-37.jpg)




![catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *)](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-42.jpg)
![catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *)](https://slidetodoc.com/presentation_image/31022dda71c9aeced482272033ef9c96/image-43.jpg)

- Slides: 44
The superhero struct wonderwoman (int) isis (superhero *) superman (int *[]) I use short internal arrows to remind myself which elements are uninitialized pointers. If a pointer is set to null, you should represent it with a line through the box, like so:
superhero marineboy[2];
superhero marineboy[2]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy
superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy
superhero *ironman; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman = &marineboy[1]; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. wonderwoman = 152; wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. wonderwoman = 152; 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[0] = new int[2]; 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[0] = new int[2]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[0]. superman[1] = &(ironman->wonderwoman); heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman->superman[0] = marineboy[0]. superman[1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman->superman[1] = &(marineboy[0]. superman[0][1]; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
ironman->superman[1] = &(marineboy[0]. superman[0][1]); heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
*(ironman->superman[1]) = 9189; heap stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
*(ironman->superman[1]) = 9189; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
marineboy[1]. isis = ironman->isis = ironman; heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
State before Barberella: heap stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman
In Barbarella: heap elektra() stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack We don’t have direct access to electra() local variables anymore. At least not by those names! 9189
barbarella(marineboy[1], ironman->isis); heap elektra() stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack These arguments are passed into barbarella, and received on the other side as….
barbarella(superhero& storm, superhero *& catwoman) heap elektra() stack 9189 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy These arguments are passed into barbarella, and received on the other side as…. ironman References! barbarella() stack storm Careful here, catwoman is a REFERENCE to a POINTER, to a superhero catwoman
storm. wonderwoman = 465; heap elektra() stack 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
storm. wonderwoman = 465; heap elektra() stack 465 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis = &storm; heap elektra() stack 465 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis = &storm; heap elektra() stack 465 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy No change! catwoman->isis is the same as catwoman, which is already pointing at the address of the object that storm references. ironman barbarella() stack storm 9189 catwoman
catwoman->wonderwoman = 830; heap elektra() stack 465 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->wonderwoman = 830; heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis[0]. superman[1] = &(storm. isis->wonderwoman); heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm 9189 Remember: isis[0] is the same as *isis. Fun fact: isis[-1] is the same as marineboy[0]! That’s because isis[-1] is the same as *(isis + (-1 * size. Of. Superhero)), or “dereference the address 1 superhero behind isis” catwoman
catwoman = &storm; heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman = &storm; heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy Another no change operation! ironman barbarella() stack storm catwoman 9189
catwoman->wonderwoman = 507; heap elektra() stack 830 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->wonderwoman = 507; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
catwoman->isis = new superhero[2]; heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189
State before barbarella exits: heap elektra() stack 507 152 wonderwoman (int) isis (superhero *) superman (int *[]) marineboy ironman barbarella() stack storm catwoman 9189