Just learning purpose to get an idea~
What are possible approaches(macros,and any other ways...) to write a generic function/Type in current FB?
Thanks in advance for the help.
Code: Select all
'pseudo code
function bigger(a as T,b as T) as T
return iif(a>b,a,b)
end function
Type Simple
public:
declare constructor(byval idValue as integer)
declare property ID() as integer
declare property ID( byval idValue as integer)
declare function toString() as string
private:
m_id as integer
End Type
Constructor Simple(byval idValue as integer)
m_id=idValue
End Constructor
Property Simple.ID()as integer
return m_id
End property
Property SImple.ID( byval idValue as integer)
m_id=idValue
End Property
Operator >(byref lhs as Simple ,byref rhs as Simple) as boolean
return (lhs.ID>rhs.ID)=true
End Operator
Fuction Simple.toString() as string
return str(m_id)
End Function
'test code
dim as integer first=1,second=2
print bigger(first,second)
dim as string str1="str1",str2="str2
print bigger(str1,str2)
dim as Simple simple1=Simple(100),simple2=Simple(200)
print bigger(simple1,simple2).toString()
sleep
end