Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Problem with inheritance

Reply
Thread Tools

Problem with inheritance

 
 
David White
Guest
Posts: n/a
 
      07-31-2003
"Victor Chew" <(E-Mail Removed)> wrote in message
news:bga9h4$f89$(E-Mail Removed)...
> I don't get it. Isn't overriding based on method signatures? There is
> clearly a difference between read(wchar_t&) and read(wchar_t*, int,
> int)!


Please read all replies, such as my other one, if you see it there. It has a
link to a thread that explains the rule and why.

DW



 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-31-2003
On Thu, 31 Jul 2003 13:45:46 +0800, Victor Chew <(E-Mail Removed)> wrote:

>I don't get it. Isn't overriding based on method signatures? There is
>clearly a difference between read(wchar_t&) and read(wchar_t*, int,
>int)! Why can't I selectively override one of the methods from the base
>class?


You can, and you just did.

It is just as static type B that one 'read' method is hidden. The other
is still there. E.g., you can cast it to A& and access the other 'read'.

David White here provided a URL to an earlier discussion where Russel
Hanneken provided a URL to an even earlier discussion where Chris Newton
tried to explain the original thinking, see [http://tinyurl.com/hlts].


> What is the workaround?


'using', as shown in my first reply.

 
Reply With Quote
 
 
 
 
Victor Chew
Guest
Posts: n/a
 
      08-01-2003
Thanks for all your replies. I support Chris' comment that "I personally
regard this decision as unfortunate". If there is a perfect method
signature match in the base class which is not overridden in the
subclass, then it should simply be used. It's the principle of least
surprise.

Alf P. Steinbach wrote:

> On Thu, 31 Jul 2003 13:45:46 +0800, Victor Chew <(E-Mail Removed)> wrote:
>
>
>>I don't get it. Isn't overriding based on method signatures? There is
>>clearly a difference between read(wchar_t&) and read(wchar_t*, int,
>>int)! Why can't I selectively override one of the methods from the base
>>class?

>
>
> You can, and you just did.
>
> It is just as static type B that one 'read' method is hidden. The other
> is still there. E.g., you can cast it to A& and access the other 'read'.
>
> David White here provided a URL to an earlier discussion where Russel
> Hanneken provided a URL to an even earlier discussion where Chris Newton
> tried to explain the original thinking, see [http://tinyurl.com/hlts].
>
>
>
>>What is the workaround?

>
>
> 'using', as shown in my first reply.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Struct inheritance against class inheritance johnsonlau C++ 1 07-21-2008 04:58 PM
Interface inheritance vs Implementation inheritance. Daniel Pitts Java 27 02-27-2008 01:37 AM
Private Inheritance and Publice Inheritance karthikbalaguru C++ 9 09-10-2007 01:05 PM
mul. inheritance & overloading operator new/delete solved by virtual base inheritance? cppsks C++ 0 10-27-2004 07:49 PM
Private access modifier and Inheritance (Inheritance implementation in Java) maxw_cc Java 1 12-21-2003 11:38 AM



Advertisments