Recently in C/C++ Category

| 0 Comments

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 {
public:
    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.

| 0 Comments

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()
T::~T()
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.

Recent Assets

  • Zuma.jpg
  • Mysterious-clouds.jpg
  • Kiffin-golf-eight-mos-small.jpg
  • Daily-run.jpg
  • Golfing-in-the-fog.jpg
  • golf-flag-snow.jpg
  • kiffinplane.jpg
  • davis-love-putting.jpg
  • Lunatech-foursome.jpg
  • Miraculous putter
  • Early-morning-golf.jpg
  • eagle-putt-hole-6.jpg

Recent Comments

  • Daily run: Make that twenty days in a row which means 7.7 x 2 ...
    - Kiffin
  • Daily run: Make that two weeks in a row which means 7.7 x 14 ...
    - Kiffin
  • Gripping the club: i have read that book too and i must say it is som ...
    - ice cream maker
  • Update CPAN modules: This command work a treat, thanks ...
    - Anonymous
  • Origin of Kyffin: My name is Kiffen**) My research led to this disco ...
    - kiffen
OpenID accepted here Learn more about OpenID

Information

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 1892 entries and as many as 1841 comments.

I graduated from Stanford 6-5-1979 ago.

I first met Thea 6-14-1980 ago.

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