On 7/1/2011 9:56 AM, Daniel Murphy wrote:
If I understand this correctly, you think the following code should be
perfectly valid:

class A { void func(uint x) in { assert(x<  10); } body {} }
class B : A { void func(uint x) in { assert(x == 50); } body {} }

Yes.

If A.func can be called with any value 0..10, why is it legal to override it
with a function that can't accept these values?

It isn't. An overriding function *must* accept all input that the overridden function does.

In other words, overriding functions accept a superset of the input, and deliver a subset of the output.


Can you give an example
where accepting input that is not a superset of the overriden function's
possible input is valid?

No.

Reply via email to