Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ARRAY member functions
#3
You cannot add member functions to ARRAY, but you can add member functions to a class containing an ARRAY.

Example:
Code:
Copy      Help
;define simple string stack class
class CStrStack -ARRAY(str)a

;examples
CStrStack st
st.Push("abc")

str s
st.Pop(s)
out s

st.Pop(s) ;;error

Member function CStrStack.Push:
Code:
Copy      Help
function $s
a[a.redim(-1)]=s

Member function CStrStack.Pop:
Code:
Copy      Help
function str&s
int i=a.len-1
if(i<0) end "stack is empty"
s=a[i]
a.redim(i)


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)