Hi,
I am new to VC++ and would like to know how can I handle the exceptions thrown from a constructor of a global static object is to be handlwed in VC++. I tried creating another global static object which sets a handler function using set_terminate method but the control is not going there. Any guidance appretiated in handling the exceptions thrown by the constructors.
Thanks and Regards,

handling the global static object constructor thrown exception in VC++ Express Edition
Kayron Mercieca
As you wrote. Constructors that throw exception are a hard thing in OOP.
The health of the program and the overall error handling is much easier when construction, creation, closing and destruction are seperated.
Stuby085
The only way to do this (and it is not perfect) is to change the constructor to use a function-try-block. For example:
class X
{
public:
X(int i, int j)
try : m_i(i), m_j(j)
{
}
catch (Exception& e)
{
}
private:
int m_i;
int m_j;
};
My question in this case is what do you do next - your program has thrown an exception during initialization: yes using this method you can handle it (even if that just means swallowing the exception) but it may do nothing to improve the overall health of your program. Of course this statement assumes that the program is only using exceptions for exceptional circumstances - if the program is using exceptions to signal events (or as I once saw to do control-flow) you have a different set of problems.
DTHMTLGOD
You run just into more troubles.
Just avoid global construction of objects than can throw!
Just place a Init methode for this job, and this Init is called when you main function starts.
Mr MTA
Hi,
I need that feature or similar features. The design is made for Unix version and I am trying to port it to Windows. I have an idea of using a flag in the class and prevent the code execution of member functions, if the constructor is not successful. But I wan't to do it in proper Object Oriented way. The output will be a shared library(dll) which will be invoked from some middle ware. So no main in my control flow. I am ready to put more effort in coding if it can be acheived. Any ideas/suggestions/hints will be appretiated.
Thanks and Regards,
K. Rose