Last active
September 26, 2016 12:56
-
-
Save yonta/a1604994c056423acaa15ec88e8f7a23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 実際はQtのライブラリであるQTimer | |
// https://github.com/radekp/qt/blob/master/src/corelib/kernel/qtimer.h#L98 | |
class DisableCopy { | |
public: | |
explicit DisableCopy(Object *parent) { // 引数ありコンストラクタ | |
// ... | |
} | |
private: | |
DISABLE_COPY(DisableCopy) // マクロでコピーが禁止されている | |
}; | |
class MainHoge { | |
//... | |
private: | |
DisableCopy dc; // クラス内部に持たせたい | |
}; | |
MainHoge::MainHoge(Object *parent) : | |
dc(DisableCopy(parent)) // <- コピーエラーが発生!なんで! | |
{ | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/_marony/status/780381727407517696
の通り,
dc
初期化にQObject*
をそのまま渡したら,実際にQTimer
を使ってもコンパイル通りましたね