I'm new to IDL and fairly new to Object Oriented programming. I'd like to be able to define a class that has variable size -- that is, different instances of the class can take up different amounts of memory.
For example, suppose I wanted to create a class called Polynomial, with the object data being an array of the coefficients of a polynomial. I would want to be able to specify the length of that array for each instance I created with a call to the OBJ_NEW routine. That way I could have one instance of the class be a quadratic, and another be a cubic, etc. (note that this is not my actual problem).
I was thinking that this might be accomplished by allowing an argument to be passed to the STRUCT__DEFINE procedure, such as
PRO POLYNOMIAL__DEFINE, degree
struct = { POLYNOMIAL, $
coeff: INTARR(degree) }
END
but this doesn't seem to work.
Is this possible in IDL (or any other language)?
Thanks,
Jared G.
|