Listing 5 (th_doubl.cpp)

//
//  class DoubleThing   --   a double thing derived from
//             class Thing.
//
//  Version 1.01  --  2/25/91
//
//  Michael Kelly --  Author
//
#include <stdio.h>
#include "th_doubl.hpp"

void DoubleThing::print()
{
    printf("%f\n", (double)*this);
}

DoubleThing::operator ==(Thing &some_thing)
{
    return ( type() == some thing.type() ) ?
      ( *((double *)ptr()) == *((double *)some_thing.ptr()) ) : 0;
}

DoubleThing::operator !=(Thing &some_thing)
{
    return !( *this == some_thing );
}

DoubleThing::operator < (Thing &some_thing)
{
    return ( type() == some_thing_type() ) ?
      ( *((double *)ptr()) <  *((double *)some_thing.ptr()) ) : 0;
}

DoubleThing::operator <=(Thing &some_thing)
{
    return ( type() == some_thing.type() ) ?
      ( *((double *)ptr()) <= *((double *)some_thing.ptr()) ) : 0;
}

DoubleThing::operator > (Thing &some_thing)
{
    return ( type() == some_thing.type() ) ?
      ( *((double *)ptr()) >  *((double *)some_thing.ptr()) ) : 0;
}

DoubleThing::operator >=(Thing &some_thing)
{
    return ( type() == some_thing.type() ) ?
      ( *((double *)ptr()) >= *((double *)some_thing.ptr()) ) : 0;
}
// End of File