I'd like to make many child classes (say B, C, D, ... with a common parent A) respond the same message "doSomething" using polymorphism in this way:
A::doSomething(A var){ // Any child will inherit this method
// it will do nothing in this case
}
B::doSomething(B var){
// does something
}
B::doSomething(A var){
// it will do nothing in this case
}
C::doSomething(C var){
// does something
}
C::doSomething(A var){
// it will do nothing in this case
}
And so on... I would like to have that priority on the message 'doSomething', so any child will respond to its specific message first (containing the same parameter type as itself) and in the default case it will respond the general parameter message.
In my case, if I do aVarB.doSomething( anotherVarB ) it always uses the method B::doSomething(A var); I'm not able to force it to go through the most specific function :/