What are virtual functions?

ShadoLight ettienne.gilbert at gmail.com
Sun Apr 18 23:04:26 UTC 2021


On Wednesday, 14 April 2021 at 14:06:18 UTC, FeepingCreature 
wrote:
> On Wednesday, 14 April 2021 at 13:43:20 UTC, Berni44 wrote:
[..]
> Covariance is related ...
[..]
>
> The opposite (contravariance) happens ...
[..]
>

Nice answer but, just to be clear - D only supports covariance on 
return types at the moment, and doesn't support contravariance on 
parameters, right?

I remember contravariance being periodically requested in the 
past but, AFAICR, it has not been implemented, right? A quick 
search through the forums didn't turn anything up either... and 
this does not compile:

```
class A {}
class B : A {}

class Y {
	public void bar (B b) {}
}
class X : Y {
	public override void bar (A a){}
}
```



More information about the Digitalmars-d-learn mailing list