how to detect object reference between objects?

  • Thread starter Thread starter fairyvoice
  • Start date Start date
F

fairyvoice

Hi, this seems more like some interview question. There is a class A and
class B and B has a instance of A, I have instance a of A and b of B, is
there any way to detect whether b has a reference pointing to a?
Thanks
 
fairyvoice said:
Hi, this seems more like some interview question. There is a class A and
class B and B has a instance of A, I have instance a of A and b of B, is
there any way to detect whether b has a reference pointing to a?
Thanks


Unfortunately the answer is maybe....

You need to answer whether the A class reference inside of class B is
public, and whether you want to test the reference in the class A, class B,
or an external object.

If the test method is in class B, then the answer is yes.
 
I mean from the outside, where I can not get the A reference of b through
some method or property of B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top