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. C / C++ / MFC
  4. array instantiation in a __gc struct ???

array instantiation in a __gc struct ???

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelptutorial
4 Posts 3 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.
  • J Offline
    J Offline
    JimWDurbin
    wrote on last edited by
    #1

    Does anyone know how to instantiate an array in a __gc structure? e.g __gc struct epdata { __int61 count; __int64 val __gc[]; // an array of integers } x; The compiler won't allow the array to be sized such as __int64 val __gc[10]; // an array of integers it gives this error message e:\xf\Form1.h(12): error C3616: '10': a size cannot be specified in a __gc array declaration This question came up when attempting to read data from the array that had been stored in the array previously. e.g x->val[0] = 2; // no error is generated on this line __int64 y = x->val[0]; // this line gives " Object reference not set to an instance of an object."

    R T 2 Replies Last reply
    0
    • J JimWDurbin

      Does anyone know how to instantiate an array in a __gc structure? e.g __gc struct epdata { __int61 count; __int64 val __gc[]; // an array of integers } x; The compiler won't allow the array to be sized such as __int64 val __gc[10]; // an array of integers it gives this error message e:\xf\Form1.h(12): error C3616: '10': a size cannot be specified in a __gc array declaration This question came up when attempting to read data from the array that had been stored in the array previously. e.g x->val[0] = 2; // no error is generated on this line __int64 y = x->val[0]; // this line gives " Object reference not set to an instance of an object."

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      You'll have to use new to allocate the array after the structure has been allocated.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      1 Reply Last reply
      0
      • J JimWDurbin

        Does anyone know how to instantiate an array in a __gc structure? e.g __gc struct epdata { __int61 count; __int64 val __gc[]; // an array of integers } x; The compiler won't allow the array to be sized such as __int64 val __gc[10]; // an array of integers it gives this error message e:\xf\Form1.h(12): error C3616: '10': a size cannot be specified in a __gc array declaration This question came up when attempting to read data from the array that had been stored in the array previously. e.g x->val[0] = 2; // no error is generated on this line __int64 y = x->val[0]; // this line gives " Object reference not set to an instance of an object."

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

        JimWDurbin wrote:

        x->val[0] = 2; // no error is generated on this line

        Humble Request pls Post Managed C++ related Question in C++/CLI[^]

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        J 1 Reply Last reply
        0
        • T ThatsAlok

          JimWDurbin wrote:

          x->val[0] = 2; // no error is generated on this line

          Humble Request pls Post Managed C++ related Question in C++/CLI[^]

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV

          J Offline
          J Offline
          JimWDurbin
          wrote on last edited by
          #4

          Thanks Alok, It has been a while since I posted anything at all. I did not know that is where question on Managed C++ questions should be posted. BTW, after a lot of hacking, the problem has been resolved.

          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