Re: Problem with covariant return types

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rob. (robert_at_xxx.fi)
Date: 06/25/04


Date: Sat, 26 Jun 2004 01:00:06 +0300


"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:ubg4IQvWEHA.3340@TK2MSFTNGP10.phx.gbl...
> Rob. wrote:
> > The following code won't compile (error C2555: 'B::f': overriding
virtual
> > function return type differs and is not covariant from 'A::f') unless I
> > moved the definitions of X and Y to before the definitions of A and B
> > respectively. Now I can understand that the compiler doesn't know that Y
is
> > derived from X when parsing B but at the very least this is a very
confusing
> > error message and I'm not sure it shouldn't be accepted.
>
> Huh? "Type differs and is not covariant" cannot be more concise and to
> the point. If you think it's "confusing", could you _please_ provide
> the message you think it should give? Thanks.

My suggestion would be:

"Cannot use covariant return types when types/classes have not been
defined"

The compiler quite clearly knows that the classes have not been defined so
why should it assume they are not covariant? It's the same situation as
trying to instantiate an undefined class.

Rob.



Relevant Pages

  • Re: Problem with covariant return types
    ... >>Would you have yet another error message when the return values are ... >>Would you give similar treatment to every compiler error, ... > yet I got an error saying they were not covariant. ... What if you never did specify that? ...
    (microsoft.public.vc.language)
  • Re: Problem with covariant return types
    ... Rob. ... Now I can understand that the compiler doesn't know that Y is ... > error message and I'm not sure it shouldn't be accepted. ... If you think it's "confusing", ...
    (microsoft.public.vc.language)
  • Re: Problem with covariant return types
    ... > Rob. ... >> why should it assume they are not covariant? ... > is what the compiler is able to conclude. ... actually a quite confusing message. ...
    (microsoft.public.vc.language)
  • Re: Cannot Close Archive Folder
    ... "Rob" wrote in message ... > I have deleted an old archive, but when I open outlook it ... > still shows the archive folder. ... > I get an error message which says "Operation Failed, ...
    (microsoft.public.outlook.general)
  • Re: mount & umount read-only floppy: unmount failed: Input/output error ??
    ... Rob wrote: ... > What might be improved is an error message from mountat the time of ... The mount command has been done and the ... I still think this falls into the category 'bug'. ...
    (freebsd-questions)