| Thread overview | |||||
|---|---|---|---|---|---|
|
September 03, 2003 question: covariance | ||||
|---|---|---|---|---|
| ||||
What's the reasoning behind this?
class A { void foo() { ... } }
class B : A { int foo() { ... } }
"function foo overrides but is not covariant with foo"
-------------------------
Carlos Santander
What's the reasoning behind this?
class A { void foo() { ... } }
class B : A { int foo() { ... } }
"function foo overrides but is not covariant with foo"
-------------------------
Carlos Santander
| ||||
September 04, 2003 Re: question: covariance | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | Carlos Santander B. wrote:
> What's the reasoning behind this?
>
> class A { void foo() { ... } }
> class B : A { int foo() { ... } }
>
> "function foo overrides but is not covariant with foo"
>
> -------------------------
> Carlos Santander
> What's the reasoning behind this?
>
> class A { void foo() { ... } }
> class B : A { int foo() { ... } }
>
> "function foo overrides but is not covariant with foo"
B.foo can't override A.foo, because it has a different (and not covariant) return type, and it can't be a simple overload, because they have the same argument list. Thus, error. :)
-- andy
| |||
September 04, 2003 Re: question: covariance | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | "Andy Friesen" <andy@ikagames.com> wrote in message news:bj6aij$1s98$1@digitaldaemon.com... | | B.foo can't override A.foo, because it has a different (and not | covariant) return type, and it can't be a simple overload, because they | have the same argument list. Thus, error. :) | | -- andy | Thanks, I hadn't noticed that. ------------------------- Carlos Santander --- Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.515 / Virus Database: 313 - Release Date: 2003-09-01 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply