Game Development Reference
In-Depth Information
class
Three : One
{
Tw o p , q ;
public
Three()
{
p=
new
Tw o (
new
One(), 1);
p.GetO().SetX(7);
q=
new
Two(p.GetO(), 2);
q.GetO().SetX(8);
p=
new
Tw o (
this
, 3);
p.GetO().SetX(9);
}
}
Make a drawing of what the memory looks like after executing:
Three t =
new
Three();
Just like the examples in this topic, make a clear distinction between the name
and the value of the variables: the name should be next to the boxes, and the
value in it. Object-references should start with a clear dot inside the box of the
reference variable, and point to the border of the object.
8.
Classes and inheritance
Given are the following class definitions:
class
A
{
public float
var1;
protected int
var2;
private bool
var3;
public float
Var1
{
get
{
return
var1; }
}
public int
Var2
{
get
{
return
var2; }
set
{
if
(
value
> 0) var2 =
value
;}
}
public void
MethodInA()
{
...
}
}