In this example, we create the spaceCraftObject_doc class, which stores a spacecraft’s name and mass. We overload the class’s _overloadHelp, _overloadImpliedPrint, and _overloadPrint methods, so that calling the help or print procedures with this class of object results in the output we desire.
            The spaceCraftObject_doc object definition and overloaded function method code listed in this section is contained in the procedure file spacecraftobject_doc__define.pro, and is located in the examples/doc/objects subdirectory of the IDL distribution. To view the file in an IDL editor window, enter .EDIT spacecraftobject_doc__define.pro at the IDL command line.
            For more information, refer to 
            FUNCTION spaceCraftObject_doc::Init, type, mass
                self.shipType = type
                self.shipMass = mass
                RETURN, 1
            END
             
            FUNCTION spaceCraftObject_doc::_overloadHelp, varname
                tempString = varname + ' = ' + '{spaceCraftObject_doc: ' $
                  + self.shipType + STRING(self.shipMass) + '}'
                  RETURN, tempString
            END
             
            FUNCTION spaceCraftObject_doc::_overloadPrint
                tempString = self.shipType + '  ' + STRING(self.shipMass) $
                    + ' kg'
                  RETURN, tempString
            END
             
            FUNCTION spaceCraftObject_doc::_overloadImpliedPrint, varname
              return, self->spaceCraftObject_doc::_overloadPrint()
            END
             
            PRO spaceCraftObject_doc__define
                struct = {spaceCraftObject_doc, INHERITS IDL_Object, $
                  shipType: '', $
                  shipMass:  0 }
            END
            Now enter the following commands in IDL:
            IDL> a=SpaceCraftObject_doc('Soyuz', 6650)
IDL> HELP, a
            IDL> PRINT, a
            IDL> a
            IDL prints:
            A = {spaceCraftObject_doc: Soyuz    6650}
            Soyuz      6650 kg
            Soyuz      6650 kg
            Notice that for the _overloadImpliedPrint method we called our _overloadPrint method. This ensures that we get the same output whether we are using Implied Print or the PRINT procedure.