Not Inheritable Classes

Hi,
I wonder if it is possible to make a class in C++ that can not be
inherited by other classes (like "final" classes in Java) and to make
member functions that can not be overrridden by child classes
(like "NotOverridable" functions in VB.net).

Thanks,

Comments

  • : Hi,
    : I wonder if it is possible to make a class in C++ that can not be
    : inherited by other classes (like "final" classes in Java) and to make
    : member functions that can not be overrridden by child classes
    : (like "NotOverridable" functions in VB.net).
    :
    : Thanks,
    :
    [blue]
    Member functions are not overridable by default.
    To override a function, it would need to be declared
    [green]virtual[/green], are the entire class an [green]ABC (Abstract Base Class)[/green].
    Child classes can, however, redefine there own versions of
    the functions--but they are not overridden by the parent class.

    Why would you want a non-overridable class, anyway?
    Thats one of the great benifets of C++.

    There *is* a way of hiding data and functions so that
    overridable classes cant access them though..(make them
    [green]private[/green] to the class).[/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion