On Thu, Mar 18, 2010 at 5:07 PM, Jos Timanta Tarigan
<[email protected]> wrote:
> im having trouble with my code. so i have a set of objects. each of this
> object has an array with different size. but i dont know yet the size, so i
> put a variable(pointer) like this:
>
> Vec3* texture;
>
> then i do some calculation and got the size of the array, so i create an
> array based on the size i found:\
>
> Vec3 array[size];
>
> and pass it to a method
>
>
> object.setTexture(array)
>
> which is like this:
>
> void setTexture(Vec3 arr*) {
> texture = arr;
> resetTexture();
> }
>
> but then i got a runtime error saying that i got a bad access. anyone know
> how can i pass an array to an object?
You're using C++, why not use vector class from STL? They are far more
flexible than low-level arrays (and can be resized on the fly) and you
don't need to mess around with pointers.
http://www.cplusplus.com/reference/stl/vector/
-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi