Why are inline constructors and destructors not a good idea in C++?

后端 未结 5 1993
夕颜
夕颜 2021-02-01 21:20

I remember reading in one of the C++ books (quite some time ago) that it is not a good idea to have inline Constructors and Destructors especially for derived class. I understa

5条回答
  •  温柔的废话
    2021-02-01 22:03

    I don't know about constructors, but destructors are very often virtual. In most cases, it doesn't make sense for the compiler to inline virtual functions, because it's not known until runtime which override is going to be called.

提交回复
热议问题