Jens Mueller Wrote:
> I like that explanation. Jonathan is saying the same, I think.
Yes, same thing.
> In C++ you cannot change a reference (I hope I'm right
> here.). When using a std::vector one does not need to think about this.
Don't know too much about C++ references, but as mentioned somewhere you can
use the Array container which won't have this issue
> What's the general use of a = new A() in the above code? Where is it
> useful?
>
> Jens
I don't really have any good use-case examples. Maybe an initialization
function? Developed your own number object (big int) and were thinking in terms
of it being a refrence you thought
a = a + BigInt(7);
would result in a being resigned in the calling function. Or maybe just a
function that swaps two class references:
void swap(T)(T a, T b) { // Correct void swap(T)(ref T a, ref T b) {
auto tmp = a; a = b; b = tmp;
}
Actually that turned out to be a pretty good one.