Re: Inheriting from std::vector?

From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 10/25/03

  • Next message: Brett: "Re: How to input 2 inputs in 1 line???"
    Date: Sat, 25 Oct 2003 14:54:43 +0200
    
    

    lilburne wrote:

    >>>>You wrote bad code, having been told it's bad. What's your point?
    >>>>
    >>>
    >>>What was bad about it?
    >>
    >>
    >> You're destroying a non-polymorphic class object polymorphically
    >> (through a pointer to the base class object).
    >>
    >> But you knew that.
    >>
    >> It's illogical to ban usage of a feature just because that feature
    >> _can_ be abused, since almost all language features _can_ be abused,
    >> and I think your use of such an illogical argument was the reason why
    >> Pete plonked you.
    >>
    >
    > It is unlikely that Pete Becker would derive a class from
    > a base that has a non-virtual destructure, without some
    > overriding reason to do so. Because he knows it is a
    > resource leak waiting to happen,

    No, it's not. Polymorphically destroying an object of that class is.
    A knife can be a useful tool, and it isn't evil. Hoever, using it to
    stab people is. Almost everything can be destructive if you want it to
    be.

    > and that safer alternatives are usually available.
    >
    > To pretend that you can ensure that the polymorphic deletion
    > on such a class heirarchy can be avoid just by saying "Don't
    > do it" is ridiculous.

    You could also reinterpret_cast the pointer to char* and delete that
    one. It will also result in improper deletion. But why would anyone do
    such a stupid thing?

    > Certain language features ought to be used with caution, IMO
    > one should learn how to use them properly before you start
    > to abuse them.

    Nope. One should learn how to use them and never abuse them at all.


  • Next message: Brett: "Re: How to input 2 inputs in 1 line???"

    Relevant Pages

    • Re: I think this is a bug...
      ... Doesn't this feature violate that concept? ... But Test_Method is passed a pointer, so it can validly be written ... AT THE VERY LEAST THIS SHOULD GENERATE A LOW-LEVEL WARNING. ... > a boxing conversion from every V to V^ to support ...
      (microsoft.public.dotnet.languages.vc)
    • Re: new laptop
      ... near-essential feature if the touchpad has to be where typing hands ... tweaks for my touchpad has like a zillion settings on it. ... them turns the pointer off while you are typing. ...
      (uk.comp.sys.laptops)
    • Re: [9fans] "Blocks" in C
      ... linked article. ... To me it seems the typical "lets come up with some cute 'feature' and ... you want to return a function, just return a pointer to it. ... Comeau C/C++ with Dinkumware's Libraries... ...
      (comp.os.plan9)
    • Re: PAPI in the ports
      ... But to have a such feature on a production system is ... If I get a problem I can easily debug ... If you cast a pointer to an integer, ... it becomes a struct. ...
      (freebsd-performance)