Why, really, deleting an incomplete type is undefined behaviour?

后端 未结 6 1772
北荒
北荒 2020-11-30 06:07

Consider this classic example used to explain what not to do with forward declarations:

//in Handle.h file
class Body;

class Handle
{
   public:
           


        
6条回答
  •  伪装坚强ぢ
    2020-11-30 06:35

    Without proper declaration of Body the code in Handle.h does not know whether destructor is virtual or even accessible (i.e. public).

提交回复
热议问题