Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Can overriding be controlled ?

Reply
Thread Tools

Can overriding be controlled ?

 
 
Vajira
Guest
Posts: n/a
 
      01-19-2005
Lets say there is a inheritance heirarchy like this. C3 inherit from C2
and C2 inherit from C1 ( C3 -> C2 -> C1 ). If C1 class has a public
virtual member function call 'Remove()', can I limit overriding this
member in C3 class ?

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      01-19-2005
* Vajira:
> Lets say there is a inheritance heirarchy like this. C3 inherit from C2
> and C2 inherit from C1 ( C3 -> C2 -> C1 ). If C1 class has a public
> virtual member function call 'Remove()', can I limit overriding this
> member in C3 class ?


I assume you mean whether you can do something in C2 such that C3
can be defined but cannot override the C1 member function.

In that case the answer is, AFAIK, no.

However, if you control the C1 implementation then you can add a dummy
argument of a private type. Then the function can only be overridden
by classes with access to that type. This does not, however, prevent
derived classes from offering a same-named function.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
Vajira
Guest
Posts: n/a
 
      01-21-2005
Thank you, This is a nice idea.
Anyway, Isn't it nice to have a keyword like 'final' in Java for C++?

 
Reply With Quote
 
Attila Feher
Guest
Posts: n/a
 
      01-27-2005
Vajira wrote:
> Thank you, This is a nice idea.
> Anyway, Isn't it nice to have a keyword like 'final' in Java for C++?


I see this request popping up many times, but I have never seen anyone
telling a good enough reason for it. I do not recall needing it ever. Of
course I don't mean it is not needed, just that I don't know if it would be
worth the trouble.

--
Attila aka WW


 
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
Can edit and delete links be controlled by user? jm ASP .Net 0 12-06-2007 08:53 PM
Mars Rover Controlled By Java Michael N. Christoff Java 146 01-05-2005 02:22 AM
running command line progs in a controlled manner kevin bailey ASP .Net 1 11-24-2004 05:10 PM
Application Controlled Authentication - Tomcat & Struts Antoine Diot Java 4 06-05-2004 12:46 AM
can minolta dimage Z1 be controlled remotely? mikko olkkonen Digital Photography 1 11-19-2003 06:36 PM



Advertisments