OO Reference

  • Thread starter Thread starter AMP
  • Start date Start date
A

AMP

Hello,
I have a Class A that creates a clB object of type Class B and a clC
object of Class C.
I have a field in clC, 'Class B localB', that I want to hold a
reference to any object of Class B.
Besides passing a parameter to the Class C constructor, how do I pass
a reference of my clB object to the localB field.
Are there multiple ways, if so could you tell me.
Thanks
 
Hello,
I have a Class A that creates a clB object of type Class B and a clC
object of Class C.
I have a field in clC, 'Class B localB', that I want to hold a
reference to any object of Class B.

You mean to one instance of class B , right?
Besides passing a parameter to the Class C constructor, how do I pass
a reference of my  clB object to the localB field.
Are there multiple ways, if so could you tell me.
Thanks

You can use a property or even a method. But note that if you do so
you are implying that the member might not be initialized and you need
to check for that before using it
 
You mean to one instance of class B , right?


You can use a property or even a method. But note that if you do so
you are implying that the member might not be initialized and you need
to check for that before using it

Examples? Yours or maybe a project (tutorial) online.
Thanks
 
Back
Top