Hallo,
i wonder how it is going to be of this code below regarding of the
return of temporary object.
Prototypes:
===========
bool Activation(TCHAR *c);
std::basic_string<TCHAR> GetFile();
Func Call:
==========
Activation((TCHAR *) myObj.GetFile().c_str());
Summary of the Question:
========================
It works fine under EVC4 & MSVC6. However, I dont know if it is
portable to g++
or other compiler.
- Is there any answer to the lifetime of temporary object for
all compilers? Does it also work fine under other compilers?
- In cosidering of effiency of the code. Is there any better solution
to just create a temporary obj like this ?
TCHAR* temp = myObj.GetFile().c_str();
Activation(temp);
- What is the lifetime of the return value from myObj.GetFile().c_str()
before Activation(..) is called?
Thank you very much for any suggestion.
regards,
pattreeya
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]