查看以下代码
public class ABC
{
public ABC(int a)
{
}
}
public struct XYZ
{
public XYZ(int a)
{
}
}
public class Test
{
//This is invalid.
ABC _abc = new ABC();
//This is valid. Why?
XYZ _xyz = new XYZ();
}
为什么struct
不要求默认构造函数与class
要求相同?