0
這是我在C++中從未見過的語法。什麼是C++中的「View()= default」?
請參閱以下內容:
class View
{
private:
int screenSize;
int screenScale; //"the ZOOM"
Point origin;
public:
const int minScreenSize = 6;
const int maxScreenSize = 30;
View():screenSize(25),screenScale(2),origin(-10,-10){}
~View() = default;
View(const View&) = default;
View(View&&) = default;
View& operator=(const View&) = default;
View& operator=(View&&) = default;
View& myAdd() = delete;
}
是什麼意思:
View() = default
和View() = delete
?
在此先感謝。
'構造函數()=默認值;' 意味着要明確編譯器生成該類的默認構造函數 '構造()= delete;' 表示您明確禁止該構造函數的用法。 –
請看這裏http://en.cppreference.com/w/cpp/language/default_constructor –
http://stackoverflow.com/questions/6502828/what-does-default-mean-after-a-class-function - 聲明,請在發佈之前快速搜索Google! – Sylvain