Advertisement

Virtual?

Started by January 19, 2003 05:42 PM
56 comments, last by John Dowis 21 years, 9 months ago
quote: Original post by ph33r
I realized I was wrong, Sark made the comment that 3 people disagree with me so I better give up. I was not trying to debate the standard I was meerly addressing the issue that people shouldn''t give up in an arguement because of the numbers on one''s oppenents size.


It wasn''t meant seriously, hence the "". Christ.
quote: Original post by SabreMan
I''ve earned a reasonable amount of money from knowing stupid stuff about it. Does that count?

I suppose it does.
quote:
Because you believe that C++ is an inferior programming language.

quote: Original post by SabreMan
Right, but I didn''t used to think that, so something caused a change.

Don''t worry, I trust what you''re saying. If I didn''t I wouldn''t bother asking you questions. All the arguments you''ve made against C++ which I have read have been very well substantiated. And it''s left me all the more eager to start messing around with Smalltalk.
"C combines all the power of assembly language with all the ease of use of assembly language"
Advertisement
I''m going back to my originial stance that you do not need to declare the base classes dtor virtual even when you call delete on it.

I did some research(with my friend''s insperation) and I found this quote in Bjarne Stroustrup''s book "The C++ Programming Language Special Edition"
quote:
page 423 Section 15.6
In other words, if you want to supply an allocator/deallocator pair that works correctly for derived classes, you must either supply a virtual destructor in the base class or refrain from using the size_t arguement in the deallocator. Naturally, the language could have been designed to save you from such concerns. Howeever, that can be done only by also "saving" you from the benefits of the optimizations possible in the less safe system.


What Stroustrup is saying is that you do not have to declare the base virtual and he left it out for people who know how to manage their memory properly and no how to deallocate memory. As Sabreman so elequently said
quote:
Sabreman
"Usually because defining the behaviour would force some implementations to utilise inefficient mechanisms for realising the behaviour. C++ sacrifices all manner of sanity at the altar of performance."

The C++ language was built to be high performance and it was built to allow you to manage your own memory that is why you have the option of declaring your base dtor to be virtual or not.

error 500
quote: Original post by ph33r
In other words, if you want to supply an allocator/deallocator pair that works correctly for derived classes, you must either supply a virtual destructor in the base class or refrain from using the size_t arguement in the deallocator.

This has nothing to do with your original claim, which is still wrong.

[edited by - SabreMan on January 23, 2003 6:19:44 AM]
He specifically says that you can use virtual dtor''s or you can refrain from using it. I''m assumming you have that book read that section.
!Nike - Just don''t do it...
Advertisement
quote: Original post by ph33r
He specifically says that you can use virtual dtor''s or you can refrain from using it.[...]

If you implement your own memory management scheme which takes care of the gory details.
Exactly sabreman

So you don''t have to have a virtual dtor if you manage your own memory which I said way back on page 2.

500x3

This topic is closed to new replies.

Advertisement