On Monday, November 08, 2010 16:11:46 so wrote: > > I like that explanation. Jonathan is saying the same, I think. I'll > > guess my misunderstanding is mainly caused by figuring out that a > > reassign is happening and that a reassign to a reference changes the > > reference. 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. > > What's the general use of a = new A() in the above code? Where is it > > useful? > > > > Jens > > Yes in C++, you can't redirect a reference after initialization. > And also can't have a std::vector of references which is mainly by this > reason.
D references are more like Java references. They're really pointers, but you don't have to dereference them, so you can reassign them to something else. You can't do that in C++, because references are treated more like name aliases of variables than pointers. So, if you think in terms of C++ pointers vs D references, then C++ and D function the same in this respect. - Jonathan M Davis
