Arrays, Vectors and Doubles?
Posted: Sat May 24, 2008 7:04 am
Hi,
I'm working through the HOC exercises from the neuron course, and I'm deeply confused by a couple of things. I do the following:
So I'm making an array with one element which is a double, and then setting it's value to 10. I'm fine with that. But if I try:
...and I get an error. I though all variables were by default doubles? What's going on here? Is it because the idea behind objref is that is should be used only for declaring variables which will be used to point to objects?
And is that why there are both arrays and vectors... an can potentially be used holding anything, and whether an array is defined with 'double' or 'objref' decides whether it is happy holding a number or an object pointer?
Finally, how do I declare an array without stating how many elements it has and/or adding elements on the fly?
I'm working through the HOC exercises from the neuron course, and I'm deeply confused by a couple of things. I do the following:
Code: Select all
double x[1]
x[0]=10
Code: Select all
objref y[1]
y[0]=10
And is that why there are both arrays and vectors... an can potentially be used holding anything, and whether an array is defined with 'double' or 'objref' decides whether it is happy holding a number or an object pointer?
Finally, how do I declare an array without stating how many elements it has and/or adding elements on the fly?