R
Ricky Lung
struct Foo {
union {
int& i;
float& j;
};
Foo(int& val) :
i((int&)val), j((float&)val)
{}
};
GCC will fail to compile the above code because multiple union member is
being initialized.
But if I modify the code to just only init the reference i:
Foo(int& val) :
i((int&)val), j((float&)val)
{}
it also pop out error because reference j is not been initialized.
What's the solution to the above problem? How the C++ standard say about
using reference in union?
--
exmat - C++ matrix library
http://exmat.sourceforge.net
~ Samba, more than a low cost File and Printer server ~
-- Let us OpenSource --
union {
int& i;
float& j;
};
Foo(int& val) :
i((int&)val), j((float&)val)
{}
};
GCC will fail to compile the above code because multiple union member is
being initialized.
But if I modify the code to just only init the reference i:
Foo(int& val) :
i((int&)val), j((float&)val)
{}
it also pop out error because reference j is not been initialized.
What's the solution to the above problem? How the C++ standard say about
using reference in union?
--
exmat - C++ matrix library
http://exmat.sourceforge.net
~ Samba, more than a low cost File and Printer server ~
-- Let us OpenSource --