Re: Inheriting from std::vector?
From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 10/25/03
- Previous message: Lasse Skyum: "Re: my own streams"
- In reply to: lilburne: "Re: Inheriting from std::vector?"
- Next in thread: lilburne: "Re: Inheriting from std::vector?"
- Reply: lilburne: "Re: Inheriting from std::vector?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: Lasse Skyum: "Re: my own streams"
- In reply to: lilburne: "Re: Inheriting from std::vector?"
- Next in thread: lilburne: "Re: Inheriting from std::vector?"
- Reply: lilburne: "Re: Inheriting from std::vector?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|