Created
August 3, 2018 04:11
-
-
Save sayurin/6b2cb95764c01d33be1589cdf38b1104 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
struct Base { | |
virtual ~Base() = default; // ... A | |
~Base() = default; // ... B | |
}; | |
struct Derived : Base { | |
~Derived() = default; // ... a | |
virtual ~Derived() = default; // ... b | |
~Derived() override = default; // ... c | |
}; | |
// Aならば | |
// a/b/cいずれでも問題ない。 | |
// ~Baseが呼ばれたとき、~Derivedも呼ばれる | |
// Bならば | |
// aのとき | |
// ~Baseが呼ばれたとき、~Derivedが呼ばれない | |
// bのとき | |
// Derivedのvtableにデストラクタが登録されるだけで特に意味はない | |
// ~Baseが呼ばれたとき、~Derivedが呼ばれない | |
// cのとき | |
// コンパイルエラーとなり問題となるコードを生成させない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment