D - question: covariance
- Carlos Santander B. (12/12) Sep 03 2003 What's the reasoning behind this?
- Andy Friesen (5/20) Sep 03 2003 B.foo can't override A.foo, because it has a different (and not
-
Carlos Santander B.
(15/15)
Sep 03 2003
"Andy Friesen"
wrote in message
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
Sep 03 2003
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
Sep 03 2003
"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
Sep 03 2003