Overloaded function disappears on polymorphism
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 24 10:55:58 PST 2015
main.d
===================================================
class Car{
public void makeBeep( char c ){}
public void makeBeep( string s ){}
}
class Tesla: Car{
override public void makeBeep( char c ){
writeln("C = ", c);
}
}
void main(){
auto t = new Tesla();
t.makeBeep("Model S");
}
===================================================
Error: function main.Tesla.makeBeep (char c) is not callable
using argument types (string)
For Tesla, I expected that makeBeep( string s ) would still be
defined. Because I have overridden on makeBeep( char c ). Isn't
that correct?
More information about the Digitalmars-d-learn
mailing list