>> If you're going to simply expose the inner array, there's little point in[color=blue][color=green]
>> even making a class since a client can simply run roughshod all over your
>> array once you've returned a pointer. I'd reconsider this design.[/color]
>
> Is there some way I could return this (read-only), so the clients can not
> change the list?[/color]
Not really. The best you can do is to return a const pointer, but even then
the caller is able to simply
cast away the const qualifier.
What you could do is to provide your own [] operator and not expose your
inner array.
that would give you the ability to implement bounds checking. your []
operator returns a copy of the actual
element, which the caller can abuse, but at least he won't mess up your
internal data.
That would result in more marshalling of course.
another thing you can do is to provide a function to which the caller has to
supply a pre allocated array that you can fill in.
As you said, there are multiple ways of doing things from which you can
choose, depending on needs and taste.
--
Kind regards,
Bruno.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"