Constructors and Inheritance

后端 未结 10 1078
臣服心动
臣服心动 2020-12-16 15:18

Lets take an example in C#

public class Foo
{
    public Foo() { }
    public Foo(int j) { }
}

public class Bar : Foo
{

}

Now, All the pu

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 15:41

    I think you can do the following:

    public class Bar : Foo
    {
      public Bar (int i)
        : base (i)
      {
      }
    }
    

    I may be a bit off -- but it's the general idea.

提交回复
热议问题