• Post Reply Bookmark Topic Watch Topic
  • New Topic

is this an aliasing ?  RSS feed

 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
Harish Shivaraj
Ranch Hand
Posts: 54
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Aliasing is when you have more than one reference to an object. For instance



You see with the above snippet object Rectangle has two reference through s1 and s2 precisely. Translating this to you code. The getFirstBuild is intended to return a reference to the object bulb1 instead of returning "new LightBulb(bulb1)". Latter would indeed create you new object. Which you certainly not intending to want.

If your after multiple references to the object bulb1 you just need to return bulb1 and assign that to new bulb2 of type LightBulb.
 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. i undetstood !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!