null value check
-
Hi all, I need to check if an object created for a class is NULL or not.... How can this be done? The code segment i had used is shown below: public ref class Class1 { private: static Class1 ^instance; private: Class1(); public: static Class1^ Instance() { if(instance == NULL) { instance = gcnew Class1(); } return instance; } }; This returns the following error: error C2065: 'NULL' : undeclared identifier Anyboby please help me out in this Thanks in advance Thanks and Regards Madhu -- modified at 4:49 Wednesday 8th February, 2006
-
Hi all, I need to check if an object created for a class is NULL or not.... How can this be done? The code segment i had used is shown below: public ref class Class1 { private: static Class1 ^instance; private: Class1(); public: static Class1^ Instance() { if(instance == NULL) { instance = gcnew Class1(); } return instance; } }; This returns the following error: error C2065: 'NULL' : undeclared identifier Anyboby please help me out in this Thanks in advance Thanks and Regards Madhu -- modified at 4:49 Wednesday 8th February, 2006
Errrr :~ You mean this:
if (MyObject == NULL) { // Do some stuff }
-
Errrr :~ You mean this:
if (MyObject == NULL) { // Do some stuff }
i think he's more asking for the C++/CLI way... not sure, but it might be something like this :
if (MyObject.IsNull()) {
//...
}
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VCalc 3.0 soon...] -
Hi all, I need to check if an object created for a class is NULL or not.... How can this be done? The code segment i had used is shown below: public ref class Class1 { private: static Class1 ^instance; private: Class1(); public: static Class1^ Instance() { if(instance == NULL) { instance = gcnew Class1(); } return instance; } }; This returns the following error: error C2065: 'NULL' : undeclared identifier Anyboby please help me out in this Thanks in advance Thanks and Regards Madhu -- modified at 4:49 Wednesday 8th February, 2006
Use nullptr in lieu of NULL for managed objects.