[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2-D arrays
Ken Kwok <kenkwok@cmu.edu> writes:
> Ah! I was using the css class int_Array. Guess I shd have stuck to
> vanilla C. So int_Array doesn't support multi-dim?
nope..
> And while we are on the subject, what diff is there betwn int arrays
> that are declared as regular C arrays and css int_Array objects apart
> from type access?
an int_Array is a c++ object that supports dynamic arrays (no need to
pre-declare the array size -- you can just add new elements as needed)
and has various member functions for accessing the array elements.
Supporting 2d with dynamic resizing is harder.. However, it is easy
to make a 1d array into a 2d array by using an index function that
takes the 2 indexes and just returns an appropriate index into a
single 1d array.. if you want a dynamic 2d array, this is what I
would recommend..
- Randy