home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!enterpoop.mit.edu!senator-bedfellow.mit.edu!bloom-picayune.mit.edu!space.mit.edu!berczuk
- From: berczuk@space.mit.edu (Steve Berczuk)
- Subject: Re: Preventing inheritance
- Message-ID: <1993Jan11.195503.6255@athena.mit.edu>
- Sender: news@athena.mit.edu (News system)
- Nntp-Posting-Host: plantagenet.mit.edu
- Organization: MIT Center for Space Research
- References: <1iqtnpINN283@news.cerf.net>
- Date: Mon, 11 Jan 1993 19:55:03 GMT
- Lines: 33
-
- In article <1iqtnpINN283@news.cerf.net>, hlf@nic.cerf.net (Howard Ferguson) writes:
- |>
- |> If I create a class which I am supplying to other users, how do I
- |> make sure that they do not inherit from it ever. I could overload new
- |> and check the size of the object that is being allocated, but there
- |> are two catchs. The first minor one is that this is a run-time check,
- |> and it would be far preferable to catch this sort of thing at compile
- |> time. More seriously, they could over-ride the new operator and by-pass
- |> the check.
- |> yours totally paranoid,
- |> hlf
- Umm, why would you want to do this?
-
- It seems like soing this sort of thing defeats the purpose fo using c++; I can
- understand not wanting to "support" other users who inherit the class, but that
- might be best approached by some sort of documentation (eg comments in the header
- to the effect of "this class supports some wierd protocols that subclasses need to
- enforce, subclass at your own risk").
-
- It is probably better to just ensure that instances of the class are always in a
- consistent state.
-
- Is there are really valid reason (aside from paranoia) that one would want to write
- a class that could not be subclassed?
-
-
-
-
-
- --
- Steve Berczuk berczuk@mit.edu
- MIT Center for Space Research (617) 253-3840
-
-