M
mathieu
Hi C++ gurus,
Why in the following code the std::string destructor is being called
before the 'catch' ?
Thanks,
-Mathieu
#include <iostream>
#include <sstream>
void foo()
{
std:stringstream os;
os << "my error";
throw os.str().c_str();
}
int main()
{
try
{
foo();
}
catch(const char *msg)
{
std::cerr << msg << std::endl;
}
return 0;
}
Why in the following code the std::string destructor is being called
before the 'catch' ?
Thanks,
-Mathieu
#include <iostream>
#include <sstream>
void foo()
{
std:stringstream os;
os << "my error";
throw os.str().c_str();
}
int main()
{
try
{
foo();
}
catch(const char *msg)
{
std::cerr << msg << std::endl;
}
return 0;
}