Reputation: 67
I am trying to create a program using windows form in c++ and i am wondering if i can throw an exception in logic.cpp and catch it with my ui.cpp
Upvotes: 1
Views: 584
Reputation: 15289
You can catch an exception that was thrown anywhere down the callstack. If the function in ui.cpp
calls the function in logic.cpp
that throws the exception then yes, you can catch it.
Upvotes: 5
Reputation: 96241
You can do this. But you need to make sure that the respective source files are compiled with the same settings and defines (and likely other things) to make sure that the exception API/ABI doesn't differ between compilation units.
Upvotes: 1