Paul Herring wrote:
> On 8/31/07, Thomas Hruska <[EMAIL PROTECTED]> wrote:
> 
>> error C2511: 'MyBase2 *MyDerived::Copy(void)' : overloaded member
>> function not found in 'MyDerived'
> 
> It appears to have something to do with the const qualifiers -
> removing the three from your example allows the code to compile. Why
> this is so, and whether it helps you I'm not too sure...

Oooookay...that's even weirder.  It definitely helps (i.e. it works for 
now).  But that seems oddly like a bug.  Why would dropping 'const' 
cause it to compile?  I wasn't doing anything non-const in the example 
that I'm aware of.  And the problem only appeared when two base class 
_paths_ (for lack of a better word) had a Copy() - using const was fine 
when there was only one base class path.

I just ran the original code through the Comeau C++ online compiler with 
their latest alpha/beta version (4.3.9) and it compiled fine under 
strict mode.


ANSI Standard Draft (I'm still too cheap :P) references:

--------------
In this International Standard, the notation cv (or cv1, cv2, etc.), 
used in the description of types, represents an arbitrary set of 
cv-qualifiers, i.e., one of {const }, {volatile }, {const, volatile}, or 
the empty set. Cv-qualifiers applied to an array type attach to the 
underlying element type, so the notation cv T, where T is an array type, 
refers to an array whose elements are so-qualified. Such array types can 
be said to be more (or less) cv-qualified than other types based on the 
cv-qualification of the underlying element types.

Table 7: relations on const and volatile
   no cv-qualifier < const
   no cv-qualifier < volatile
   no cv-qualifier < const volatile
   const < const volatile
   volatile < const volatile
--------------

--------------
The return type of an overriding function shall be either identical to 
the return type of the overridden function or covariant with the classes 
of the functions. If a function D::f overrides a function B::f, the 
return types of the functions are covariant if they satisfy the 
following criteria:
   - both are pointers to classes or references to classes(104)
   - the class in the return type of B::f is the same class as the class 
in the return type of D::f, or is an unambiguous and accessible direct 
or indirect base class of the class in the return type of D::f
   - both pointers or references have the same cv-qualification and the 
class type in the return type of D::f has the same cv-qualification as 
or less cv-qualification than the class type in the return type of B::f.

(104) Multi-level pointers to classes or references to multi-level 
pointers to classes are not allowed.
--------------

As far as I can tell, the original code should work based on what I'm 
reading above.  Everything had the same cv-qualifier and I wasn't doing 
anything non-const'ish.  Additionally, given that the "most 
Standards-compliant compiler" (Comeau C++) compiles my code, I say this 
is a compiler bug.

I just asked around.  Apparently the original code works fine in VS.NET 
2005.  I'm still going to wait for "Orcas" before upgrading.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/



To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to