Why can't a method be virtual AND static at the same time?

ed growlercab at gmail.com
Thu Jan 30 15:17:25 PST 2014


On Thursday, 30 January 2014 at 13:24:09 UTC, Steven 
Schveighoffer wrote:
[snip]
>
> The issue you have is with the naming, you can't overload a 
> virtual function with a static one. A static function call is a 
> different call than a virtual one. You can't mix the two.
>
> -Steve


Actually you can do this, see my other post. Overloading a static 
method with a virtual method or vice-versa works fine. You cannot 
do is override a static method because it isn't virtual and is 
nonsensical IMO.

The OP said they expected overloading to occur in response to 
another post:

[snip]
> What do you mean? The methods have different signatures (static 
> x virtual)
[snip]

so I don't know why they were thinking to override, probably just 
a simple mistake.

Cheers,
ed


More information about the Digitalmars-d mailing list