c++ - What are the disadvantages of having one base class for all exceptions? -


i'm doing exercises stroustrup's c++ programming language 4th edition. 1 of tasks formulated this:

consider using class exception base of classes used exceptions. should like? how should used? might do? what disadvantages might result requirement use such class?

the answer looks pretty std::exception, save disadvantages part - 1 can imagine cost of __vptr considered negligible. missing here?

the disadvantage if try catch exception @ bottom of inheritance tree, catch exceptions derived one, , of them might indicate things different expecting. worse, developer used lot of functions may throw exceptions, , doesn't know of them mean, might catch base class, exception, , return unspecific exception instance when encountering errors, making difficult debug code, , possibly causing whole program fail because of fixable exception shouldn't cause problems.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -