The superhero struct wonderwoman int isis superhero superman
- 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
- Sum0
- Struct node int data struct node* next
- Typedef struct tree
- Typedef struct tree
- Typedef struct node
- Public int divide(int a int b)
- Int max(int x int y)
- Interface calculator public int add(int a int b) class test
- Public void drawsquare(int x, int y, int len)
- Isis super hero
- Copying structs in c
- Struct node int i float j
- Struct node *next
- Typedef struct tree int info
- What are structure
- Struct point int x y
- Struct point int x y
- Struct node int data
- Struct sample int a=0
- Typedef struct in c
- Char argv
- Nnxn com
- Void swap
- Int factorial(int n)
- Int f(int n)
- Interface myinterface int foo(int x)
- Const int arduino
- Int.max
- Int main int argc char argv
- Int main int num 4
- Be present at our table lord prayer
- Doctor blight captain planet
- Superman sentence
- Superman xyy
- Interpreting velocity time graphs
- Umberto eco superman
- A famous swashbuckling trio
- Uji rank spearman
- Gejala psikis
- Name something you associate with superman
- Famous swashbuckling trio of old
- Superman and paula brown's new snowsuit themes
- Superman
- Bill has $10 to spend on a superman batman
- Superman hero's journey