"Rustam Asgarov" <ru****@boun.edu.tr> wrote in message
news:Or**************@TK2MSFTNGP11.phx.gbl...
how can i access variables defined in the parent class from the child
class: By some way other than passing as parameter to constructor.
I mean.
class Parent{
public int b;
public Method()
{
b = 5;
Child child = new Child();
}
}
class Child{
public Method()
{
int a = b; // to do this..
}
}
I don't think it is possible. What if I defined:
class OtherParent
{
private Child _myChild;
public OtherParent(Child theChild)
{
_myChild = theChild;
}
}
Which "parent" should be used now?
By the way: "child classes" usually refers to classes that are defined (as
opposed to "used")
inside some parent class. Like:
class Parent
{
class Child
{ ... }
...
}
In this case "Child" CAN refer to fields (even private!) of "Parent".
Hans Kesting