Listing 3 (anyclass.hpp)

// anyclass.hpp
// declaration of anyClass, a test
// class, and declaration of
// RefCntPtr to anyClass

#ifndef CLASS_anyClass
 #define CLASS_anyClass
 
 #include "refptr.hpp"
 #include "refitem.hpp"
 
 #include <iostream.h>
 
 class anyClass : public RefCntItem
  {
   public:
    
    int intVal;
    char *string;
    
    anyClass (void)
      : RefCntItem()
      , intVal(0)
      , string(0)
      {
        cout << "anyClass constructor\n\n";
      };
    
    ~anyClass (void)
      {
        cout << "anyClass destructor\n";
        show();
      };
    
    void show(void)
      {
        cout << "anyClass contents:\n"
            << intVal <<""
            << string << "\n"
            << "reference count: "
            << refCnt() << "\n\n";
      };
  };
 
 RefCntPtrDECLARE(anyClass)

#endif
// End of File