| Specialization, Extension, and Inheritance - slide 32 : 40 |
class A {}
class B: A{}
class Client{
public static void Main (){
// Static type Dynamic type
A x; // A -
B y; // B -
x = new A(); // A A TRIVIAL
y = new B(); // B B TRIVIAL
x = y; // A B OK - TYPICAL
y = new A(); // B A Compile time ERROR
// Cannot implicitly convert type 'A' to 'B'.
y = x; // B B Compile time ERROR !
// Cannot implicitly convert type 'A' to 'B'.
}
}







