473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UnOverRideable member functions?

Is it possible to define a member function of an object to be
Un-OverRideable?

The function also needs to be seen by the outside world so it can not be a
private member.
Jul 23 '05 #1
5 1086
Michael P. O'Connor wrote:
Is it possible to define a member function of an object to be
Un-OverRideable?

The function also needs to be seen by the outside world so it can not
be a private member.


Yes, but only on a tecnicality -- only virtual functions can be
overridden, so a non-virtual function is un-overridable.

OTOH, a derived class can still create another function with the same
name, hiding the base class function even if its not virtual (though
some tools will warn about this, since it's rarely desirable).

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #2
Is there a way to cause the compiler to not just give a warning but to
error out?

On Thu, 03 Mar 2005 21:47:15 -0800, Jerry Coffin wrote:
Yes, but only on a tecnicality -- only virtual functions can be
overridden, so a non-virtual function is un-overridable.

OTOH, a derived class can still create another function with the same
name, hiding the base class function even if its not virtual (though
some tools will warn about this, since it's rarely desirable).


Jul 23 '05 #3
"Michael P. O'Connor" <mp**@mikeoconnor.net> wrote in message
Is there a way to cause the compiler to not just give a warning but to
error out?


Some compilers let you escalate any warning into an error through command
line switches or compiler option dialog boxes. I'm not aware of a way to do
it in the language.
Jul 23 '05 #4
Michael P. O'Connor wrote:
Is there a way to cause the compiler to not just give a warning but
to error out?


I know of switches for the compilers I use to make them treat all
warnings, or specific warnings, as errors, but I don't know of a way to
write the code so all it's what the language considers an error,
requring all compilers to diagnose the problem.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #5
Michael P. O'Connor wrote:
Is it possible to define a member function of an object to be
Un-OverRideable?


Don't declare it virtual.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wenjie | last post by:
Hello, I read someone posted assertions that even the (public) member function is not static, there are probably only one copy of the code in the executable. Then except the...
4
by: 0to60 | last post by:
I don't know if I have that terminology right, but does anyone know if static member functions (or free standing functions for that matter) are any less overhead than actual member functions that...
2
by: Thomas Matthews | last post by:
Hi, I have a hierarchy of classes and would like to create an array of pointers to member functions that could also contain pointers to the parent member functions as well. What is the syntax...
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
12
by: Anthony Jones | last post by:
Just a bit of background: I'm one of a group of FORTRAN programmers, looking to switch to C++. We are trying to write a few simple examples to demonstrate the power of the language to our manager,...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
22
by: ypjofficial | last post by:
Is there any possibility of invoking the member functions of a class without creating an object (or even a pointer to ) of that class. eg. #include <iostream.h> class test { public: void...
13
by: JohnQ | last post by:
The implementation of classes with virtual functions is conceptually easy to understand: they use vtables. Which begs the question about POD structs: how are they associated with their member...
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.