Re: denying inheritance
From: Micah Cowan (micah_at_cowan.name)
Date: 10/30/03
- Next message: Micah Cowan: "Re: denying inheritance"
- Previous message: Micah Cowan: "Re: 2-dimensional arrays and functions"
- In reply to: Gary Labowitz: "Re: denying inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Oct 2003 12:12:57 -0800
"Gary Labowitz" <glabowitz@comcast.net> writes:
> "Micah Cowan" <micah@cowan.name> wrote in message
> news:m33cdbu8rx.fsf@localhost.localdomain...
> > "Novice" <cassidy@cs.queensuDOTca> writes:
> >
> > > Is there a way (in C++) to stop developers from being able to derive a
> class
> > > that you create?
> > Simply don't declare them "virtual". They'd still be able to
> > derive from the class, and still override the member
> > functions... BUT, when accessed as your original class type,
> > *your* functions are still the ones that will be called, since
> > their non-virtualness means that the implementation won't bother
> > checking to see if there are "newer" versions of those functions.
> >
> > Not having a virtual destructor really should keep sane people
> > from deriving from your class most of the time, I hope.
>
> Dumb question: can you inherit from a class if you don't have the source? Or
> a header?
Only if you otherwise define the class in your source, *exactly*
as originally defined. If you
don't have some access to class information, this is pretty much
impossible, so in short, the answer is "No."
-- Micah J. Cowan micah@cowan.name
- Next message: Micah Cowan: "Re: denying inheritance"
- Previous message: Micah Cowan: "Re: 2-dimensional arrays and functions"
- In reply to: Gary Labowitz: "Re: denying inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|