implement vs override
Peter C
peterc at gmail.com
Fri Oct 31 23:49:06 UTC 2025
On Friday, 31 October 2025 at 23:36:57 UTC, Quirin Schroll wrote:
> On Friday, 31 October 2025 at 22:58:04 UTC, Peter C wrote:
>> NOTE: It's just an idea, not a proposal.
>>
>> I'm a big fan of clarity in design.
>>
>> Clarity is what makes your design understandable and
>> maintainable.
>>
>> 'implement' - implements an abstract/interface method -
>> First-time definition
>>
>> 'override' - overrrides a concrete base method - Replaces or
>> extends existing logic
>
> This is a good idea for nomenclature in documentation, but it
> doesn't work with the language. You can implement an interface
> method by inheriting from a class that defines the method
> without the base class implementing the interface.
ok. interesting...
interface IGreeter
{
void greet();
}
class Base
{
void greet() {}
// Really, there should be a complier error here.
// e.g "Error: Method 'greet' matches both a base class and
interface signature."
// so ok...what to do here?? remove or rename?
// I don't think Base should sucessfully compile under this
circumstance.
}
class Derived : Base, IGreeter
{
}
More information about the Digitalmars-d
mailing list