Hi there,
I come across some MC++ code like this:
__gc class ClassA
{
Puclic:
ClassB GetClassB();
}
__gc class ClassB
{
Public:
int Value;
}
int main()
{
ClassA^ a = gcnew ClassA();
ClassB^ b = a->GetClassB();
int c = b->Value;
}
Isn't it important to check whether b is NULL before access to its value? I tried if(b == NULL)
, but it dosen't work.
Or it's really not necessary to do the check? however I can hardly believe it...
Thanks.
Echo.
PS: I only want to know whether the "Reference" itself could be NULL here. Whether the content of class B is null isn't important.