programming:継承時のコンストラクタ呼び出し
差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| programming:継承時のコンストラクタ呼び出し [2017/08/09 04:39] – 作成 dot | programming:継承時のコンストラクタ呼び出し [2017/08/09 04:48] (現在) – dot | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | |||
| + | ====== 実行結果 ====== | ||
| + | |||
| + | <code sh> | ||
| + | $ dotnet run | ||
| + | This is SuperClassSample Constructor.Argument is 1234 | ||
| + | This is ChildClassSample Constructor. | ||
| + | </ | ||
| + | |||
| + | ====== ソース ====== | ||
| 行 25: | 行 35: | ||
| public class ChildClassSample : SuperClassSample | public class ChildClassSample : SuperClassSample | ||
| { | { | ||
| - | // we need "base(1)" because compiler can not know how to call SuperClass Constructor. | + | // we need "base(some integer variable)" because compiler can not know how to call SuperClass Constructor. |
| - | public ChildClassSample() : base(1) | + | public ChildClassSample() : base(1234) |
| { | { | ||
| Console.WriteLine(" | Console.WriteLine(" | ||
| 行 33: | 行 43: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | |||
programming/継承時のコンストラクタ呼び出し.1502253555.txt.gz · 最終更新: by dot
