Hello
In exception handling if you have a collection of exception types that are related through inheritance and the catch blocks take in a reference to the object thrown any base-class reference is able to refer to derived-class objects but if you pass it by value a base-class reference shouldn't recognize a derived-class object. But running my program I get the same results passing by value or reference.
This work fine but when you swap bad1 catch-block with bad2 catch-block you'll continuously catch bad1 which is too be excepted but when you pass by value you get the same results
when the catch blocks are order this way I'm getting the same results.
I'm pretty sure I'm misunderstanding something here.
Sorry for the silliness of the program I was just trying to see the difference between reference vs value with exceptions since a temporary object is created either way.
Thanks for any help.
g++ ex.cpp
ex.cpp: In function ‘int main()’:
ex.cpp:66: warning: exception of type ‘bad2’ will be caught
ex.cpp:62: warning: by earlier handler for ‘bad1’