Improve Your Programming with Asserts
By Bruce D. Rosenblum
Dr. Dobb's Journal December 1997
(a) h = GlobalAlloc(size_t, flags); if(h ++ NULL) ASSERT(h != NULL, "Allocation failed"); else DoThis(h); (b) m_pBtn = new CButton (); ASSERT(m_pBtn != NULL, "Button not instantiated");
Example 1: (a) Do not assert memory errors. (b) Code to avoid in source files.
Copyright © 1997, Dr. Dobb's Journal