Monday, October 11, 2010

Calling a Virtual Function in A Base Constructor or Destructor

You should never call a virtual function in a base constructor or destructor.

If your compiler is nice, it will generate code that will tell you this. Otherwise, I maybe hard to debug. Indirect calls to virtual functions add another layer of difficulty to debugging.

   More Exceptional C++ by Herb Sutter. Addison-Wesley, 2002., p. 170.

No comments:

Post a Comment