L
LK
Why wouldn't c# catch the following problem at compile
time (as C++ does)?
class EmbClass
{
public int TestVar;
public EmbClass( int i )
{
TestVar = i;
}
}
struct ComplexStruct
{
/* **************PROBLEM************
Not saying here that EmbClass does not have a default
constructor!
*/
public EmbClass DefaultsHow;
public int m_j;
}
static void Main( )
{
ComplexStruct CS = new ComplexStruct( );
//correctly throws a Null-Reference exception
int i = CS.DefaultsHow.TestVar;
}
time (as C++ does)?
class EmbClass
{
public int TestVar;
public EmbClass( int i )
{
TestVar = i;
}
}
struct ComplexStruct
{
/* **************PROBLEM************
Not saying here that EmbClass does not have a default
constructor!
*/
public EmbClass DefaultsHow;
public int m_j;
}
static void Main( )
{
ComplexStruct CS = new ComplexStruct( );
//correctly throws a Null-Reference exception
int i = CS.DefaultsHow.TestVar;
}