Intuition informs me the more the tossed type, the greater. Better throw an int than the usual pointer, better throw a struct than the usual class. Within this situation though it's important to throw a nearly full class with dynamically allotted people. It's easy to allocate memory within the heap because buffers can become quite lengthy and copying be costly it do not need to have techniques since it functions like a control/argument struct for other objects, but it's easy to both construct it within the heap to throw a pointer to struct and to possess a destructor to wash up memory. The more the greater, so if the destructor be virtual? Is it more beneficial to omit a vtable or vtables don't affect whatsoever exception passing?

The benefit of drawing classes out of this struct as base class is always to increase the data, to not polymorph techniques. The pointer might be caught several layers ahead in the exception point and become passed among modules, therefore the object should work as clean as you possibly can and also have very little chance of adding to errors as you possibly can.

Take a look at std::exception and inherit from that.

A destructor should simply be virtual should you expect individuals to make use of the class like a base class.

An online destructor is just necessary when removing an item using a pointer to some base class. Within the situation of exception types, you shouldn't be creating them dynamically, but tossing by value. So there's you don't need to remove them, using a base class pointer or else, and thus no requirement for an online destructor.

With that said, the price of a v-table is small in comparison using the dynamically-allotted data you mention, and in comparison with the price of tossing the best whatsoever, and you ought to always favour utility over efficiency unless of course there is a proven have to optimise. I would suggest you derive all of your exception types from std::exception to ensure that you are able to handle errors tossed by your code and also the standard library (along with other libraries) inside a uniform way. This already includes a virtual function (what(), coming back a note string) along with a virtual destructor.