How to use base class & child class as parameter in one function ?

Vinod K Chandran kcvinu82 at gmail.com
Fri May 22 21:39:16 UTC 2020


On Friday, 22 May 2020 at 20:51:20 UTC, Steven Schveighoffer 
wrote:
> On 5/22/20 4:04 PM, Vinod K Chandran wrote:
>> [...]
>
> Yes. What you cannot do is this (which I hope doesn't compile 
> in VB.net, but I wouldn't be surprised):
>
> Dim sampleList As New List(Of Child)
> sampleList.Add(New Base(10))
>
> Which is the equivalent of what you were requesting.
>
> -Steve
Nope--
List(Of Base) will contain an instance of a Child.
So in the same manner, i want
void function(Base) = fnPtr wiil work with
void function(Child)



More information about the Digitalmars-d-learn mailing list