© { JSL }
38
struct vs class
struct
Pair
{
int
x, y;
...
}
Pair p =
new
Pair(1,2);
Pair copy = p;
p.x
stack
heap
class
Pair
{
int
x, y;
...
}
Pair p =
new
Pair(1,2);
Pair copy = p;
1
2
@
p
@
copy
1
2
p.y
copy.x
copy.y
.x
1
2
.y