C++: Throwing an exception invokes the copy constructor?

后端 未结 6 1124
半阙折子戏
半阙折子戏 2021-01-07 14:02

We have an custom error class that is used whenever we throw an exception:

class AFX_CLASS_EXPORT CCLAError : public CObject

It has the fol

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 14:34

    The language specification allows the compilers to make as many copies of the original object as they want. There is no restriction on the number of copies.

    That means, your custom exception class must have an accessible copy-constructor, either the compiler generated one, or user-defined one.

提交回复
热议问题