@Drol,
Thank you for explaining how to copy and paste from the console window. I feel I need to point out, because it appears it wasn't clear in my original post. The program I posted was written by Bjarne Stroustrup and is designed to elicit a specific output that the reader is supposed to try to understand. HE decided to use single letters for the variable names. HE decided the upon format of the program.
The entire output is below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
004241A0->X(int):0(2)
0012FF54->X(int):-858993460(4)
0012FF48->X(X&):-858993460(4)
0012FD54->X(int):-858993460(5)
0012FF54->X::operator = ():4(5)
0012FD54->~X():5(0)
0012FD30->X(X&):702684171(5)
0012FD6C->X(X&):-858993460(5)
0012FD30->~X():5(0)
0012FF48->X::operator = ():4(5)
0012FD6C->~X():5(0)
0012FD30->X(X&):702684171(5)
0012FD10->X(X&):-858993460(5)
0012FD84->X(X&):-858993460(5)
0012FD10->~X():5(0)
0012FD30->~X():5(0)
0012FF48->X::operator = ():5(5)
0012FD84->~X():5(0)
0012FF3C->X(int):-858993460(6)
0012FD14->X(int):-858993460(7)
00345A48->X(X&):-842150451(7)
0012FD14->~X():7(0)
00345A48->~X():7(0)
0012FD14->X(int):-858993460(8)
00345A48->X(X&):-842150451(8)
0012FD14->~X():8(0)
00345A48->~X():8(0)
0012F7D8->X():-858993460(0)
00345AE0->X(X&):-842150451(0)
0012F7D8->~X():0(0)
0012F7D8->X():0(0)
00345AE4->X(X&):-842150451(0)
0012F7D8->~X():0(0)
0012F7D8->X():0(0)
00345AE8->X(X&):-842150451(0)
0012F7D8->~X():0(0)
0012F7D8->X():0(0)
00345AEC->X(X&):-842150451(0)
0012F7D8->~X():0(0)
0012FF04->X():-858993460(0)
0012FF08->X():-858993460(0)
00345B30->X(int):-842150451(9)
00345B30->~X():9(0)
00345B34->X():-842150451(0)
00345B38->X():-842150451(0)
00345B3C->X():-842150451(0)
00345B40->X():-842150451(0)
00345B44->X():-842150451(0)
00345B44->~X():0(0)
00345B40->~X():0(0)
00345B3C->~X():0(0)
00345B38->~X():0(0)
00345B34->~X():0(0)
|
I have thought more about the program and believe that on line 7: 'this' refers to the memory address, 's' refers to the name and type of the variable, 'val' refers to the value of the variable, I don't know what 'nv' refers to, perhaps array size.
So the when the global variable X glob(2) is created on line 36 it constructs a variable of size 2 at memory address 004241A0, name X and type int, of value 0. The address suggests to me that this variable was put in stack memory. Because it is global, it is never destroyed. That address is never written again.
I think line 37 copies 'glob(2)' to 'a', and 'a' is put into memory address 0012FF54, a heap memory address. It again has name X and is of type int. Line 38 copies 'a' to 'aa' and puts into memory address 0012FF48, again heap memory and the address is declining as heap addresses should (I think).
Am I in the ball park or way, way off?