Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Prevent subclass from overriding method (http://www.programmingforums.org/showthread.php?t=12320)

ssrun Jan 7th, 2007 1:27 AM

Prevent subclass from overriding method
 
Hi,

Is there a way to prevent subclasses from overriding a method in the base class? Essentially, is there an equivalent of a final method like in Java?

grumpy Jan 7th, 2007 1:55 AM

No.

It, however, possible to prevent any derivation from a class which, in turn, prevents overriding of any member functions (aka methods).

Eric the Red Jan 7th, 2007 2:22 AM

You might want to look into "c++ Polymorphism".

ssrun Jan 7th, 2007 12:05 PM

Quote:

Originally Posted by grumpy (Post 122272)
No.

It, however, possible to prevent any derivation from a class which, in turn, prevents overriding of any member functions (aka methods).

How can you prevent derivation from a class?

DaWei Jan 7th, 2007 12:51 PM

Mr. Sroustrup speaks. See here.

Bench Jan 7th, 2007 12:54 PM

Have a look here -
http://www.parashift.com/c++-faq-lit....html#faq-23.9


All times are GMT -5. The time now is 1:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC