P
Peter Oliphant
This is possibly some other problem, but here goes anyway. I created a
'value struct'. I then created a stack semantic instance of it. I then
created a method that takes a pointer to such an instance, and changed one
of its components. I then tried this code, and it didn't change the
instance's component. Code is something like this:
value struct vStruct
{
int x ;
} ;
namespace MyGlobal
{
void Zero_vStruct( vStruct^ vs ) { vs->x = 0 ; }
} ;
void main()
{
vStruct vs ;
vs.x = 58 ;
MyGlobal::Zero_vStruct( %vs ) ;
int vsx = vs.x ; //still 58, not 0 !!!
return 0 ;
} ;
If I change vStruct to a 'ref struct' it works, but then I can't create an
array of such values without it being an array of pointers to such
instances. That is:
typedef array<vStruct> vStruct_Array_A ; //illegal if ref, legal if value
typedef array<vStruct^> vStruct_Array_B ; // always legal
So, I'm asking this: what do I pass to a method as a parameter so I can
change the component values of an instance of a value struct?
For context, I'm using VS C++.NET 2005 using clr/ure syntax...
Thanks in advance for reponses! : )
[==P==]
'value struct'. I then created a stack semantic instance of it. I then
created a method that takes a pointer to such an instance, and changed one
of its components. I then tried this code, and it didn't change the
instance's component. Code is something like this:
value struct vStruct
{
int x ;
} ;
namespace MyGlobal
{
void Zero_vStruct( vStruct^ vs ) { vs->x = 0 ; }
} ;
void main()
{
vStruct vs ;
vs.x = 58 ;
MyGlobal::Zero_vStruct( %vs ) ;
int vsx = vs.x ; //still 58, not 0 !!!
return 0 ;
} ;
If I change vStruct to a 'ref struct' it works, but then I can't create an
array of such values without it being an array of pointers to such
instances. That is:
typedef array<vStruct> vStruct_Array_A ; //illegal if ref, legal if value
typedef array<vStruct^> vStruct_Array_B ; // always legal
So, I'm asking this: what do I pass to a method as a parameter so I can
change the component values of an instance of a value struct?
For context, I'm using VS C++.NET 2005 using clr/ure syntax...
Thanks in advance for reponses! : )
[==P==]