Given the following:
public class A
{
public A()
{
}
}
public class B : A
{
public int b;
public B()
{
}
}
public A a = new B();
print(a.b); // I'd like to have many classes that inherit from A, and storing
// one of them on a single variable. Then access the variables that belong to the //derived class
My goal here is to create several classes that inherit from a base class. Then assign one of the classes to a variable (whose type must be of type "A") and access the variables of the derived class. Is it possible?
Ashould generally not know anything aboutB. In fact that hardly contradicts the LISKOW-principle.