I have doubt in C++ exception :
#include <iostream>
#include <string>
using namespace std;
void some_function()
{
string str("Hello,World!");
throw(str);
}
int main()
{
try
{
some_function();
}
catch (string& e)
{
cout << e << endl;
e = "Hello, the world!";
cout << e << endl;
}
return 0;
}
debug in my PC:
- in
some_function
thestr
addr:0x003CF820
- int
main
thee
addr:0x003CF738
I have three question,
- catch parameter is
string&
, why we get diff addr in main() ? - is
str
not a temp value ? why we can use a temp value reference ? - where is
e
store in memory ?
can some one help me ? thanks .