C#代码片段:
public class XmlConfig : IDisposable
{
static public XmlConfig LoadedCfgx { get { return loaded; } }
}
public class ConfigRetainerRingPresenter
{
public ConfigRetainerRingPresenter(XmlConfig config)
{
}
}
C ++ / CLI代码片段:
ConfigRetainerRingPresenter g(XmlConfig::LoadedCfgx);
ConfigRetainerRingPresenter ^h = gcnew ConfigRetainerRingPresenter (XmlConfig::LoadedCfgx);
编译器错误:
1>h:\configinterop.cpp(58): error C3673: 'Config::ConfigRetainerRingPresenter' : class does not have a copy-constructor
1>h:\configinterop.cpp(59): error C3673: 'Config::ConfigRetainerRingPresenter' : class does not have a copy-constructor
有人可以向我解释为什么程序期望复制构造函数吗?
编辑:为ConfigRetainerRingPresenter()添加了默认构造函数,错误消息消失了。我没有使用默认构造函数。有人可以解释一下吗?
public ConfigRetainerRingPresenter() { }