Inheritance of purity
Martin Nowak
dawg at dawgfoto.de
Fri Feb 17 06:28:05 PST 2012
> No. Absolutely not. I hate the fact that C++ does this with virtual. It
> makes
> it so that you have to constantly look at the base classes to figure out
> what's
> virtual and what isn't. It harms maintenance and code understandability.
> And
> now you want to do that with @safe, pure, nothrow, and const? Yuck.
It's different from virtual. Virtual is an implicitly inherited loosening
attribute
while @safe, pure, nothrow and const are restricting.
It could be potentially confusing when introducing new overloads.
But that is also detected easily.
class Base
{
void foo() const
{
}
}
class Derived : Base
{
override void foo()
{
}
void foo() const
{
}
}
More information about the Digitalmars-d
mailing list