Category: C/C++


So why the heck would you or anyone else ever want to define a virtual destructor? Have a look at the following code:

class Blah {
    virtual ~Blah() {}
// more code

Note here that the body of the virtual destructor is empty. What gives?

When you think about it more closely, you cannot help but realize that this is necessary. Whenever a pointer to the Blah class is used to delete an object that might actually be a derived-class object, then be careful, e.g. a virtual destructor is required unless you enjoy blowing up your program in unpredictable ways.

Since this destructor is inherited by the derived classes there is no need to redefine this destructor in the derived classes.


If your class needs a destructor, it probably needs a copy destructor and an assignment operator too. In other words, you can look at it this way:

T::T(const T&)
T::operator=(const T&)

In the long run it is probably a better idea to make it a habit always to include all of these for a given class, just in case.

Random entries

Here are some random entries that you might be interested in:

Recent Assets

  • Ryder-cup-2015.png
  • jong-tegen-oud-2015.png
  • Rijnmond-open-2.png
  • Rijnmond-open-1.png
  • one-hundred-and-fifty-thousand.png
  • Handicap-versus-scores.png
  • Nearly-a-hole-in-one.png
  • last-slice-of-cake.png
  • golfing-maniac.png
  • 3e-ngf-maandbker-cromstrijen-results.png
  • 3e-ngf-maandbker-cromstrijen.png
  • RESTful-Rails-Development-book.png

Recent Comments

  • Bridge to the moon: Yes it was a drawing and my older brother told me ...
    - jpmcfarlane
  • Bridge to the moon: Wow, that's quite a coincidence that we both sent ...
    - Kiffin
  • Bridge to the moon: Hello I was in my teens when Gemini 4 went up that ...
    - jpmcfarlane
  • Back to work: Congratulations Kiffin, I hope it is something you ...
    - KathleenC
  • Buddha shrine: I keep Buddhas in my plants outside on the deck du ...
    - KathleenC

Golf Handicap


This personal weblog was started way back on July 21, 2001 which means that it is 7-21-2001 old.

So far this blog contains no less than 2197 entries and as many as 1876 comments.

Important events

Graduated from Stanford 6-5-1979 ago.

Kiffin Rockwell was shot down and killed 9-23-1916 ago.

Believe it or not but I am 10-11-1957 young.

Began well-balanced and healthy life style 1-8-2013 ago.

My father passed away 10-20-2000 ago.

First met Thea in Balestrand, Norway 6-14-1980 ago.