假设我有这门课:
class foo
{
public foo(Guid guid)
{
//some code here
}
public foo(Guid guid, bool myBool)
{
//some other code here
}
//Here I have a bunch of method/properties
public void GenX(bool french, int width)
{
//my method implementation
}
}
我有另一个类,foo
除了这个方法的实现public GenX(bool french, int width)
和构造函数必须与foo
's 的实现不同之外,它的作用基本相同。
如果我bar
以这种方式实现,编译器会抱怨:'foo' does not contain a constructor that takes '0' arguments
class bar : foo
{
public bar(Guid guid, bool myBool)
{
//some code here
}
new public void GenX(bool french, int width)
{
//my new method implementation
}
//I will be using the implementation of `foo` for the rest of the methods/properties
}
我究竟做错了什么?这是做这种事情的正确方法吗?
如果这还不够清楚,我很抱歉,我会尽量让它更清楚