07
Inheritance
towards polymorphism

Constructors
in derived classes

Principle of
substitutibility

Polymorphism and
polymorphic method calls

Casting
references

Labs

Not inherited!

Default constructor of base class is called

Can invoke alternative base class constructor via : base(...)

Object of derived type should be able to be used
wherever an object of base type was expected
(because it just "adds" extra features)

Can use base type reference to refer to
object of derived type

Take base type as parameter to method

Return base type from method

Store collection of base type references

References include what type they are

Base method marked as virtual

Derived method marked as override

Actual method called decided at runtime

Downcasting via (type)

Downcasting safely via "is" or "as"

Testing racing cars

Employee hierarchy

Traffic light simulator