Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 7th, 2007, 1:27 AM   #1
ssrun
Newbie
 
Join Date: Aug 2006
Posts: 20
Rep Power: 0 ssrun is on a distinguished road
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?
ssrun is offline   Reply With Quote
Old Jan 7th, 2007, 1:55 AM   #2
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,254
Rep Power: 5 grumpy will become famous soon enough
No.

It, however, possible to prevent any derivation from a class which, in turn, prevents overriding of any member functions (aka methods).
grumpy is offline   Reply With Quote
Old Jan 7th, 2007, 2:22 AM   #3
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
You might want to look into "c++ Polymorphism".
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old Jan 7th, 2007, 12:05 PM   #4
ssrun
Newbie
 
Join Date: Aug 2006
Posts: 20
Rep Power: 0 ssrun is on a distinguished road
Quote:
Originally Posted by grumpy View Post
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?
ssrun is offline   Reply With Quote
Old Jan 7th, 2007, 12:51 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Mr. Sroustrup speaks. See here.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jan 7th, 2007, 12:54 PM   #6
Bench
Newbie
 
Join Date: Feb 2006
Posts: 20
Rep Power: 0 Bench is on a distinguished road
Have a look here -
http://www.parashift.com/c++-faq-lit....html#faq-23.9
Bench is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to invoke static method from a Class object? smith.norton Java 1 Oct 5th, 2006 4:00 AM
DiveLog.java tutorial help Arenlor Java 2 Apr 26th, 2006 11:11 AM
method doesn't recognize variable Krista Java 1 Dec 5th, 2005 6:40 PM
Median/Mode in arrays? {Need help} Java|Tera Java 27 Nov 29th, 2005 11:50 AM
Debug recursion method() pr0gm3r Java 3 Oct 11th, 2005 1:33 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:27 AM.

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