1) For convenience I have my entire program in a try block. This way I can throw an exception at any point in my code and know that it will be handled the same way. As the program becomes larger will this technique cause a hit in performance?
2) If objects are de-allocated when out of scope, why would throwing a temporary object be valid? e.g.:
class Error : public std::exception
{
private:
char *m;
private:
Error(char *l) : m(l) {}
virtual char *what()
{
return m;
}
};
int main()
{
try
{
throw Error("test");
}
catch(std::exception &e)
{
puts(e.what());
return -1;
}
return 0;
}
In the throw statement, why wouldn't the temporary object become invalid since it's been declared only in the try scope?
3) With Windows operating systems of a language other than English, would the what() member of the STL exception class still return a char* string? Or could it return a wchar_t* string?