Skip to content

Instantly share code, notes, and snippets.

@yonta
Last active September 26, 2016 12:56
Show Gist options
  • Save yonta/a1604994c056423acaa15ec88e8f7a23 to your computer and use it in GitHub Desktop.
Save yonta/a1604994c056423acaa15ec88e8f7a23 to your computer and use it in GitHub Desktop.
// 実際は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)) // <- コピーエラーが発生!なんで!
{
// ...
}
@ncaq
Copy link

ncaq commented Sep 26, 2016

https://twitter.com/_marony/status/780381727407517696

の通り,dc初期化にQObject*をそのまま渡したら,実際にQTimerを使ってもコンパイル通りましたね

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment