onion
2009-12-26 07:58:01 UTC
I try to compile :
union
{
int v1;
int test ( int p) { return p+p;}
} uniontest;
void main ( void)
{
uniontest.v1=5;
int res = uniontest.test(10);
printf("res=%d\n",res);
}
All Ok. The compiler translate code to program with no errors or warning.
If running the program work correctly and show the right result 20.
In the ansi c++ directive don't describe the function as elements of a union.
What is the utility of function into a union ? I don't know.
It seems the microsoft compiler use the union at the same mode of struct.
bye to all
Angelo
union
{
int v1;
int test ( int p) { return p+p;}
} uniontest;
void main ( void)
{
uniontest.v1=5;
int res = uniontest.test(10);
printf("res=%d\n",res);
}
All Ok. The compiler translate code to program with no errors or warning.
If running the program work correctly and show the right result 20.
In the ansi c++ directive don't describe the function as elements of a union.
What is the utility of function into a union ? I don't know.
It seems the microsoft compiler use the union at the same mode of struct.
bye to all
Angelo