>>难道继承以后,构造函数还要重写吗?
No. If you don't tell wich constructor you will use, the system will use the constructor without any parameter.
There are 3 ways,
1. The first is yours.
2. The second, give some values in the default constructor of class A
>>public A
>>{count = 0;}public A
{
count = 0;
x = 0;
y = 0;
}3. The third:
Create a constructor in class B, tell it call which constructor of A:
class B:A
{
public B:base(0,0);
{}
}
No. If you don't tell wich constructor you will use, the system will use the constructor without any parameter.
There are 3 ways,
1. The first is yours.
2. The second, give some values in the default constructor of class A
>>public A
>>{count = 0;}public A
{
count = 0;
x = 0;
y = 0;
}3. The third:
Create a constructor in class B, tell it call which constructor of A:
class B:A
{
public B:base(0,0);
{}
}
>>B b=new B(2,3);For the constructor, the sub class couldn't inherited from his parent class.So the 2 ,3 is not right.You must write a constructer like 1.
class B:A
{
public B(int x, int y):base(x,y)
{}
}