cout << "  new IFoo@" << STATIC_CAST(void*, this) << " [#" << total_constructions_ << "]" << endl;
printf("  new IFoo@%p [#%d]\n", STATIC_CAST(void*, this), total_constructions_);
              void  set_a_IFoo( nsCOMPtr<IFoo>* result );nsCOMPtr<IFoo>  return_a_IFoo();unsigned int IFoo::total_constructions_;unsigned int IFoo::total_destructions_;class test_message  {    public:      test_message()        {          cout << "BEGIN unit tests for |nsCOMPtr|, compiled " __DATE__ << endl;        }     ~test_message()        {          IFoo::print_totals();          cout << "END unit tests for |nsCOMPtr|." << endl;        }  };test_message gTestMessage;  /*    ...  */voidIFoo::print_totals()  {    cout << "total constructions/destructions --> " << total_constructions_ << "/" << total_destructions_ << endl;  }IFoo::IFoo()    : refcount_(0)  {    ++total_constructions_;    cout << "  new IFoo@" << STATIC_CAST(void*, this) << " [#" << total_constructions_ << "]" << endl;  }IFoo::~IFoo()  {    ++total_destructions_;    cout << "IFoo@" << STATIC_CAST(void*, this) << "::~IFoo()" << " [#" << total_destructions_ << "]" << endl;  }nsrefcntIFoo::AddRef()  {    ++refcount_;    cout << "IFoo@" << STATIC_CAST(void*, this) << "::AddRef(), refcount --> " << refcount_ << endl;    return refcount_;  }nsrefcntIFoo::Release()  {    int wrap_message = (refcount_ == 1);    if ( wrap_message )      cout << ">>";          --refcount_;    cout << "IFoo@" << STATIC_CAST(void*, this) << "::Release(), refcount --> " << refcount_ << endl;    if ( !refcount_ )      {        cout << "  delete IFoo@" << STATIC_CAST(void*, this) << endl;        delete this;      }    if ( wrap_message )      cout << "<<IFoo@" << STATIC_CAST(void*, this) << "::Release()" << endl;    return refcount_;  }nsresultIFoo::QueryInterface( const nsIID& aIID, void** aResult )	{    cout << "IFoo@" << STATIC_CAST(void*, this) << "::QueryInterface()" << endl;		nsISupports* rawPtr = 0;		nsresult status = NS_OK;		if ( aIID.Equals(GetIID()) )			rawPtr = this;		else			{				nsID iid_of_ISupports = NS_ISUPPORTS_IID;				if ( aIID.Equals(iid_of_ISupports) )					rawPtr = STATIC_CAST(nsISupports*, this);				else					status = NS_ERROR_NO_INTERFACE;			}		NS_IF_ADDREF(rawPtr);		*aResult = rawPtr;		return status;	}nsresultCreateIFoo( void** result )    // a typical factory function (that calls AddRef)  {    cout << ">>CreateIFoo() --> ";    IFoo* foop = new IFoo;    cout << "IFoo@" << STATIC_CAST(void*, foop) << endl;    foop->AddRef();    *result = foop;    cout << "<<CreateIFoo()" << endl;    return 0;  }voidset_a_IFoo( nsCOMPtr<IFoo>* result )  {    cout << ">>set_a_IFoo()" << endl;    assert(result);    nsCOMPtr<IFoo> foop( do_QueryInterface(new IFoo) );    *result = foop;    cout << "<<set_a_IFoo()" << endl;  }