Is there a way to disable constructor synthesizing on a class?

前端 未结 2 1022
星月不相逢
星月不相逢 2020-12-16 00:01

Suppose I have a class that I want to make sure my compiler (GCC in this case) doesn\'t synthesize any constructors or assignment methods for. I\'ve found one way to do this

2条回答
  •  情书的邮戳
    2020-12-16 00:44

    The classical way is to declare them, but never implement. Most people would expect that declaration to be private or protected.

    In C++0x, you can explicitly delete them. Which does pretty much the same thing, but is way nicer to read.

提交回复
热议问题