 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Raider Guest
|
Posted: Thu Jun 22, 2006 9:10 am Post subject: reference to the temporary object |
|
|
is such code correct?
#include <string>
typedef std::string T;
T *s;
const T& foo(const T& default)
{
if (s) return *s; else return default;
}
int main()
{
const T& value = foo("bar");
// use value
}
I think the "bar" must be destroyed immediatly when foo() returns. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|