Last active
August 29, 2015 14:14
-
-
Save ufcpp/44c3439146acf073ab38 to your computer and use it in GitHub Desktop.
Complete type hierarchy
This file contains hidden or 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
| abstract class Message | |
| { | |
| // コンストラクターを private に | |
| private Message() { } | |
| // inner クラスであれば private なコンストラクターにアクセスできる | |
| // なので、以下の A, B, C はコンパイルできる | |
| public sealed class A : Message { } | |
| public sealed class B : Message { } | |
| public sealed class C : Message { } | |
| } | |
| // private なコンストラクターのせいで外からは継承できない | |
| public class D : Message { } // なので、ここでコンパイル エラー | |
| // しかも、A, B, C ともに sealed なので、そいつらを継承することもできない |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment