29 Replies
they want me to draw the memory after running the Three t command
i cant figure it out even with the answer
i start with class three : one right?
oh, you're supposed to graphically represent the objects and their references?
ye
how do i start
Three
makes sense, since that is your entrypoint, and also the only class with only 1 instance
I'd start with drawing three and the two fields inside it.Ok
p = new Two(new One(), 1);
the first command
what do they mean with new One
the
new
keyword creates an instance of a class.... in this case One
it refers to class one right
because the constructor for
Two
expects a One
and an int
yes, it creates an instance of class onebut what does the , 1 mean
^
ooh
that's the constructor for two
but class three : one
cant access class two?
what do you mean by can't access it exactly?
its in a different class
Two and Three are classes
you can't really say Two is "in" a different class... it is a class of its own
ye
but dont i need a reference to access information about class two
so you are creating an instance of class two
like with inheritance i can access information about class 1
you aren't yet acessing information about it
this isn't accessing anything, it's creating
oh oke
again, the
new
key word creates an instance of a class
so new Two(...)
is creating a instance of Two
what does it take as argument
p = new Two(new One(), 1);
for this one it takes int c = 1
and b = new One?
yes
ah i think i get it now
thanks for the help
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.