Files
harbour-core/harbour/tests/working/overload.prg
1999-05-15 11:55:01 +00:00

58 lines
1.0 KiB
Plaintext

#define MET_METHOD 0
#define MET_DATA 1
#define MET_CLASSDATA 2
#define MET_INLINE 3
#define MET_VIRTUAL 4
//
// DynObj
//
// Implementation of operator overload in Harbour
//
// Date : 1999/05/15
//
function Main()
local oString := TString():New( "Hello" )
QOut( oString:cValue )
if oString == "Hello"
QOut( "Ok" )
if oString != "Hello"
QOut( "Not ok" )
endif
endif
return nil
function TString()
static oClass
if oClass == nil
oClass = TClass():New( "TSTRING" ) // starts a new class definition
oClass:AddData( "cValue" ) // define this class objects datas
oClass:AddMethod( "New", @New() )
oClass:AddInline( "==", {| self, cTest | ::cValue == cTest } )
oClass:AddInline( "!=", {| self, cTest | ::cValue != cTest } )
oClass:Create() // builds this class
endif
return oClass:Instance() // builds an object of this class
static function New( cText )
local Self := QSelf()
::cValue := cText
return Self