In Java, when I do
Foo bar = new Foo();
bar will be a variable containing the address of the newly constructed object. My professor call it a reference variable
The previous line is equivalent to this in C++:
Foo *bar = new Foo();
here, bar is a pointer to the object
So, is it true that a reference variable in Java is basically a pointer?
Also, when I do this in C++:
Foo bar;
is bar also a pointer? If not, then does that mean there is a difference in memory structure between
Foo bar;
and
Foo *bar = new Foo();
?