UnOverRideable member functions?

  • Thread starter Michael P. O'Connor
  • Start date
M

Michael P. O'Connor

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.
 
J

Jerry Coffin

Michael said:
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).
 
M

Michael P. O'Connor

Is there a way to cause the compiler to not just give a warning but to
error out?
 
S

Siemel Naran

Michael P. O'Connor said:
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.
 
J

Jerry Coffin

Michael said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,052
Members
47,656
Latest member
rickwatson

Latest Threads

Top