Lets say I have three classes Alpha, Beta and Gamma. Alpha instances Beta as myBeta. Beta has a non-static public variable called accessMe. Now, I can access the variable from Alpha as myBeta.accessMe. I can also access it from Beta as accessMe (of course). My question is how do I access it from Gamma. If I try to access it as Beta.accessMe, the compiler complains that I am referencing a non-static variable from a static context (which is true since "Beta." makes it static). Since I havent instanced Beta in Gamma, I can't refer to it as myBeta.accessMe. I don't want to make betaString static. I don't want to pass myBeta as a parameter to Gamma, nor do I want to make Gamma an Inner Class. I just want to access accessMe, a public variable. Isn't there some easy obvious way to do this?
2006-11-05
14:22:34
·
2 answers
·
asked by
heartsensei
4