Sunday, 8 September 2013

accessing private member of member class

accessing private member of member class

I have a class A, with a private member int myMember. And a class B with a
private member of the class A, called myA;
That is:
public class A{
private int myMember;
...
}
public class B{
private A myA;
}
I would like to be able to access:
B.myA.myMember;
but it seems I can't because myMember is private in A. The thing is, I
need A to be defined as private for the purpose of the exercise (that also
includes it can't be protected). Is there a way around this?
Thanks.

No comments:

Post a Comment