class a
{
public int var1;
private string var2;
protected decimal var3;
}
class b:a
{
var1=10;
var2;//Inherited but not accessible.
var3= 199.25;
}
a= new class b();---> Reference variable of class a is been given an object of class b .(Allowed)
Here i can access the parent class members but cannot access the child class members even though the object given is child class. why?
However in the above inheritance we get all all the members inherited in child class but private is not accessible. why cant this be possible in the case of
a= new class b();
b= new class a();---> Reference variable of class b is been given an object of class a .(Not allowed).--As a child class reference variable cannot refer to a parent class object.