|
On Sun, 2006-10-22 at 18:14 -0400, Qiwen Chen wrote:
> For the last couple days, i was trying to figure out how to assign
> values to Array class. As far as i know, there is no method in Array
> class that allow me to define the array by a Real array, which can be
> initialized very easily. Thanks for your help.
Qiwen,
if you mean something like
Array a = { 1.0, 1.5, 2.0, 2.5, 3.0 };
that's not possible in C++ (at least at this time---as far as I know,
the C++ standard committee is thinking of making it possible, but that
means changing the language and waiting for all compilers to be updated.
It will take years.) The same problem applies to any container, e.g.,
std::vector; it's not just our Array.
Given the current implementation, one has to initialize an Array of the
correct size and copy the Real array into it. We could add an Array
constructor taking two iterators, so that one could write
Real x[] = { 1.0, 1.5, 2.0, 2.5, 3.0 };
Array a(x, x+5);
but that's the best we can end up with.
Later,
Luigi
----------------------------------------
Newton's Law of Gravitation:
What goes up must come down. But don't expect it to come down
where you can find it. Murphy's Law applies to Newton's.
|