On Sun, 13 Nov 2005 16:04:43 -0800, "Carl Daniel [VC++ MVP]"
<cp*****************************@mvps.org.nospam > wrote:
Peteroid wrote: I believe this is not allowed:
union comboVar
{
int i;
double d ;
};
ref class myClass
{
comboVar m_Var_1 ; // error, no unions in ref class
comboVar* m_Var_2 ; // error no pointers either
comboVar^ m_Var_3 ; // error, not these either
} ;
Is there a /clr union equivalent?
No, there is not. The CLR doesn't support unions.
-cd
Actually, you can simulate unions with explicit layouts and field
offests. Ex:
using namespace System::Runtime::InteropServices;
[StructLayout(LayoutKind::Explicit)]
value class comboVar
{
public:
[FieldOffset(0)]
int i;
[FieldOffset(0)]
double d;
};
Austin