Re: 'virtual' can only be used....
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 05/25/04
- Next message: Rob Williscroft: "Re: 2 variable "nested" loop with TMP"
- Previous message: Leor Zolman: "Re: How is string::c_str() usually implemented?"
- In reply to: cppaddict: "Re: 'virtual' can only be used...."
- Next in thread: cppaddict: "Re: 'virtual' can only be used...."
- Reply: cppaddict: "Re: 'virtual' can only be used...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 25 May 2004 15:39:24 -0400
cppaddict wrote:
>>Write it as
>>
>> virtual Rectangle const& getNameDisplayRect(int) const = 0;
>>
>>(your first 'const' is in the wrong place)
>
>
> Victor,
>
> Thanks for your response. Unfortunately, this change didn't help.
>
> As a side note, are you sure the way I have it is wrong? I thought
> that "Rectangle& const" means "A reference which cannot be changed
> that refers to a rectangle" whereas "Rectangle const&" means "A
> reference (which can be changed) that refers to a Rectangle which
> cannot be changed". Thus both are legal. Am I wrong here?
Yes.
References cannot be changed (according to their nature) and therefore
cannot be cv-qualified. The standard explicitly prohibits qualifiers
for references.
>>Another guess is that 'Rectangle' is somehow
>>a macro that has some template thing in it, and you don't know of
>>it because the actual "Rectangle.h" file being included is not
>>the one you provided, but some system file from some other package
>>(happened to me once with a header named "data.h" -- very original
>>name, isn't it?)
>
>
> This isn't the case, either. Rectangle.h is a file I wrote, it's an
> extremely simple class with no macros.
>
> Any other ideas?
Begin eliminating stuff from your program until it compiles. Thus you
will isolate the offending part. Then create a small test program with
it and see if you got it right. If after that you still don't see the
reason why the compiler is complaining, post the small test program and
we can discuss it.
Victor
- Next message: Rob Williscroft: "Re: 2 variable "nested" loop with TMP"
- Previous message: Leor Zolman: "Re: How is string::c_str() usually implemented?"
- In reply to: cppaddict: "Re: 'virtual' can only be used...."
- Next in thread: cppaddict: "Re: 'virtual' can only be used...."
- Reply: cppaddict: "Re: 'virtual' can only be used...."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|