Quote:Original post by smrQuote:Original post by MaulingMonkey
Neither. They're both the exact same thing, internally. Just different syntax used.
Heck, I wouldn't be suprised if this worked on many compilers:
*** Source Snippet Removed ***
I'm not going to try it, but it shouldn't work. Every time the compiler accesses a reference it should always dereference before any casts are applied. So you will end up trying to make a pointer of first sizeof(ofstream*) bytes actual data within the object, which the compiler shouldn't let you do.
I'm not following what you're saying. But the fact of the matter is that the function does NOT take the object by value - it is a REFERENCE! Since this is not the actual data - just an under the hood pointer - there is no data truncation occuring here.
Quote:Well I did try it, and although I certainly don't recommend doing this in any shape or form it seems to work fine under both BCB and GCC. I even tried passing a derived class by pointer/reference to base and calling a virtual method and it worked fine.
Enigma
Scary.
Quote:IIRC, it is possible to create a 'null' reference, but the result is undefined.
Correct. And we all know, undefined is programmer-speak for "STEP AWAY FROM THE BUTTON BEFORE YOU RELEASE THE HOARDS OF GIANT BLUE MONKEYS!!!".