Making inheritance less tedious
Kevin Bealer
kevinbealer at gmail.com
Mon Feb 26 19:23:27 PST 2007
Kristian Kilpi wrote:
>
> I think class inheritance is a bit(?) tedious sometimes (that is,
> unnecessarily tedious).
> (I leave interfaces out of this discussion.) 'Problems', IMHO, with it are:
>
> 1) You cannot inherit constructors.
>
> 2) A function will hide inherited functions having the same name.
I think 2) is considered a feature and done deliberately to prevent
certain kinds of errors. I never thought much about the details though.
As for (1), I agree and this is something that annoys me in C++ too.
Something like this syntax might be in line with D's solution for #2.
class X : Y {
alias Y.this this;
}
Though I imagine the underlying implementation would be different than
for a non-constructor method, this syntax looks clear, to me at least.
Kevin
More information about the Digitalmars-d
mailing list