array instantiation in a __gc struct ???
-
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."
-
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."
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"
-
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."
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
-
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
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.