G
Guest
Hi, quick question:
I have a function which takes a reference to an object as an argument.
void foo( vect3 & v );
This works fine:
vect3 v1(0.0, 0.0, 0.0);
foo(v1);
This also works fine, in VC++ .NET:
foo(vect3(0.0, 0.0, 0.0))
g++ has a fit with the second one though. I can see why it might, since the vect3() constructed object won't last very long. But my question is, does the C++ standard state somewhere that the object will last long enough for the function to evaluate it (by referencing it!) ?
Thanks!
P.S. I've posted here a lot in the past, and as far as I can remember, every post, someone has pointed out that's my post belongs in another group. I think this question is finally on-topic! ;-)
I have a function which takes a reference to an object as an argument.
void foo( vect3 & v );
This works fine:
vect3 v1(0.0, 0.0, 0.0);
foo(v1);
This also works fine, in VC++ .NET:
foo(vect3(0.0, 0.0, 0.0))
g++ has a fit with the second one though. I can see why it might, since the vect3() constructed object won't last very long. But my question is, does the C++ standard state somewhere that the object will last long enough for the function to evaluate it (by referencing it!) ?
Thanks!
P.S. I've posted here a lot in the past, and as far as I can remember, every post, someone has pointed out that's my post belongs in another group. I think this question is finally on-topic! ;-)