Nicolas Alvarez <nic### [at] gmail com> wrote:
> int& foo() {
> int myNumber = 42;
> return myNumber;
> }
> Undefined behavior when the caller tries to do something with the reference.
I think there's a reason why you can't have references to primitive
types in Java.
(Sometimes this can be a bit limiting, eg. because you can't pass
primitive types by reference to functions, for them to modify the
original values rather than copies.)
--
- Warp
Post a reply to this message
|