Figure 2    MYEDIT's CClock Object

Mainfrm.h

////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal. 
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 5.0 on Windows 95
// 
#include "Clock.h"

class CMainFrame : public CFrameWnd {
    •
    •
    •
protected:
       CClock m_clock; // clock object

       // command router
       virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
                             AFX_CMDHANDLERINFO* pHandlerInfo);
};
Mainfrm.cpp
////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal. 
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 5.0 on Windows 95
// 
#include "StdAfx.h"
    •
    •
    •
////////////////
// Command router: this function routes commands to clock,
// then to rest of system.
// 
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra,
   AFX_CMDHANDLERINFO* pHandlerInfo)
{
   // If you remove the comments below, the menu commands will
   // be disabled because without routing the command to the clock,
   // MFC thinks there is no handler for it.
   //
//#ifdef NEVER
   if (m_clock.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
      return TRUE;
//#endif
   return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

Clock.h
////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal. 
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.

//////////////////
// Clock object is a command target that implements its own menu commands.
//
class CClock : public CCmdTarget {
public:
      CClock();
      virtual ~CClock();

protected:
      CMyDoc();
      void NotImplemented();

      DECLARE_DYNAMIC(CClock)
      DECLARE_MESSAGE_MAP()
      void afx_msg OnSetTime();
      void afx_msg OnCheckTime();
};

Clock.cpp
////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal. 
// If this program works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CClock represents any object that can handle menu commands.
// CClock handles two commands: Clock | Set Time and Clock | Check Time
//
#include "StdAfx.h"
#include "Resource.h"
#include "Clock.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNAMIC(CClock, CCmdTarget)

BEGIN_MESSAGE_MAP(CClock, CCmdTarget)
   ON_COMMAND(ID_CLOCK_SET,   OnSetTime)
   ON_COMMAND(ID_CLOCK_CHECK, OnCheckTime)
END_MESSAGE_MAP()

CClock::CClock()
{
}

CClock::~CClock()
{
}

////////////////
// Handle commands, Clock | Set Time
//
void CClock::OnSetTime()
{
   NotImplemented();
}

////////////////
// Handle commands, Clock | Check Time
//
void CClock::OnCheckTime()
{
   NotImplemented();
}

void CClock::NotImplemented()
{
   AfxMessageBox(_T("So sorry, I don't know how to do that.\n"));
}

Figure 4   Abstract.cpp


 ////////////////////////////////////////////////////////////////
 // 1998 Microsoft Systems Journal. 
 // If this code works, it was written by Paul DiLascia.
 // If not, I don't know who wrote it.
 // To compile, type:
 //
 //   cl Abstract.cpp
 //
 // Illustrates pure virtual destructor
 // 
 
 #include <iostream.h>
 
 class Animal {
 public:
     Animal()  { }
     // pur virtual destructor
     virtual ~Animal() = 0;
 };
 
 //////////////////
 // This function is called even though it's pure!
 //
 Animal::~Animal()
 {
     cout << "bye-bye Animal";
 }
 
 class MadCow : public Animal {
 public:
     MadCow()  { }
     ~MadCow() { cout << "bye-bye MadCow\n"; }
 };
 
 void main()
 {
     Animal* pa = new MadCow;
     delete pa;
 }