Covariant generic interface with antiallergic

First, anti-covariant generic interface becomes

1, with antiallergic covariant generic interface for parameter exists generic interface class inheritance, the subclass generally variable exists an implicit conversion that is the parent class object is assigned to handle new class the parent class is defined by the type of security conversion, and the rule covariant antiallergic properties the generic interface is used in the expression, and improve the flexibility of the code, its purpose is implicit conversion between types.

 

2, covariant

Covariance is a subclass of a generic interface objects given to the parent class that is a subclass of the class of the parent process, the implicit type conversion rules which are safe, it is to define its parameter spread out declared label (or type of security checking reported abnormal), came parameter indicates that the process is a generic interface to create a subclass object to the right of return to the parent left the generic interface defined by the implicit conversion.

 

3, resistance to change

Antiallergenic parent process is a generic interface objects given to the parent class that is a subclass of a subclass, the subclass generally parent class is not a non-secure implicit type conversions, so the definition of which is passed the parameters declared in the label using ( otherwise, the type of security check will be reported anomaly), passing parameters indicate that the process is to define the parameters of the parent class is now parameter passed subclass object is to achieve the purpose implicit conversion.

 

Summary: covariant antiallergic and ultimately are subclasses of the parent class to the type of security implicit conversion, meaning that the direction of change covariant same subclass to superclass, and resistance to change is the parent of its subclasses change to the opposite direction.

ps: the reference object is present there is only one implicit type conversion, i.e., sub-object type to convert an object reference type parent reference.

Guess you like

Origin www.cnblogs.com/tuqunfu/p/12536008.html