This does not work as normal Code: class test { private: class privateStruct { public: int m; privateStruct(int p){m=p;} }; }; void ff() { test::privateStruct ps(4); throw ps; //Does not work.. } void main() { try { ff(); } catch(...) { } } but the code below works Code: class test { private: class privateStruct { public: int m; privateStruct(int p){m=p;} }; }; void ff() { throw test::privateStruct(4); //Work why } void main() { try { ff(); } catch(...) { } } How??
Probably a bug in VC compiler. Its creates a Nameless temporary object at throw test::privateStruct(4); Or similar statements like return test::privateStruct(4); and probably VC is not tested for such conditions well enough.