digitalmars.D.learn - TDPL 6.4.3 Overriding Is Only Voluntary
- Caligo (8/8) Mar 22 2011 "The override keyword in the signature of Friend.bgColor is required," (...
- Jesse Phillips (3/14) Mar 23 2011 This is probably due to compiler not enforcing the rule. There is no dif...
"The override keyword in the signature of Friend.bgColor is required," (193)
This code compiles:
class Contact{ string bgColor(){ return ""; } }
class Friend : Contact{
string bgColor(){ return "LightGreen"; }
}
So how is 'override' required? Can I get an example of where
'override' makes a difference?
Mar 22 2011
Caligo Wrote:
"The override keyword in the signature of Friend.bgColor is required," (193)
This code compiles:
class Contact{ string bgColor(){ return ""; } }
class Friend : Contact{
string bgColor(){ return "LightGreen"; }
}
So how is 'override' required? Can I get an example of where
'override' makes a difference?
This is probably due to compiler not enforcing the rule. There is no difference
from having the 'override' and not having it. What it provides is documentation
that the function comes from the parent and it will throw an error if you are
not overriding a function. As this documentation is so useful it is considered
as something that should just be required even though the compiler knows what
is being overridden.
the same name and signature, I don't know its importance.
Mar 23 2011








Jesse Phillips <jessekphillips+D gmail.com>