构造函数中的问题 [英] Problem in constructor
本文介绍了构造函数中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个OrderItemcl类.而且它没有任何默认构造函数.
当我在TestOrderItemcl中继承此类时,它给出错误消息.
OrderItem不包含任何接受0参数的构造方法.
I have a class OrderItemcl. and it has not any default constructor.
When i inherit this class in TestOrderItemcl it gives error msg.
OrderItem does not contain any constructor that takes 0 argument.
推荐答案
将以下内容添加到OrderItem类中:
Add the following to your OrderItem class :
public class OrderItem
{
public OrderItem() //add this
{
}
// rest of your code
}
在子类上使用构造函数,该子类将基(父)构造函数调用为:
use a constructor on the child class that calls base (parent) constructor as :
public child(int i) : base(i)
确保您使用适当的类型,我在这里使用过int.
谢谢,
Kuthuparakkal
Make sure you use appropriate types, I used int i here.
Thanks,
Kuthuparakkal
这篇关于构造函数中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文