Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. null value check

null value check

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    madhusri
    wrote on last edited by
    #1

    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

    C R 2 Replies Last reply
    0
    • M madhusri

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Errrr :~ You mean this: if (MyObject == NULL) { // Do some stuff }

      T 1 Reply Last reply
      0
      • C Cedric Moonen

        Errrr :~ You mean this: if (MyObject == NULL) { // Do some stuff }

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        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...]

        1 Reply Last reply
        0
        • M madhusri

          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

          R Offline
          R Offline
          Red Stateler
          wrote on last edited by
          #4

          Use nullptr in lieu of NULL for managed objects.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups