| Author |
want to know the benefit of using reference variable like Emp e2=e1
|
Neeraj Goyal
Greenhorn
Joined: Feb 01, 2012
Posts: 2
|
|
|
problem is that i have used Emp e2=e1; e1 and e2 are the reference variables. and just passing e1 into e2 and accesing the functions by e2 reference variable. Just want to know what is the benefit of accesing by using Emp e2=e1.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 7602
|
|
Welcome to the Ranch.
In future, please CarefullyChooseOneForum I have moved your posts from the JNLP forum because they are not related to JNLP.
I have also closed the other post, which was almost similar to this one.
|
[Donate a pint, save a life!] [How to ask questions]
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3141
|
|
Neeraj Goyal wrote:problem is that i have used Emp e2=e1; e1 and e2 are the reference variables. and just passing e1 into e2 and accesing the functions by e2 reference variable. Just want to know what is the benefit of accesing by using Emp e2=e1.
All by itself, that's pointless. But maybe you have a situation like this:
In this case, we want to do something with a particular Emp object, but we have to pick which one based on some condition. So we use a separate variable for a copy of the reference to the object we're interested in. If we didn't do that, we'd have to either duplicate all the code that uses e3 into both if and else, making sure to change the variable names after copy/pasting.
|
 |
 |
|
|
subject: want to know the benefit of using reference variable like Emp e2=e1
|
|
|