Macros to disallow class copy and assignment. Google -vs- Qt

前端 未结 11 1268
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 06:22

To disallow copying or assigning a class it\'s common practice to make the copy constructor and assignment operator private. Both Google and Qt have macros to make this eas

11条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 07:12

    Both serve the same purpose

    Once you write this one:

    Class &operator=(const Class &);
    

    you will get the benefits of chain assignments. But in this case you want the assignment operator to be private. so it doesn't matter.

提交回复
热议问题