遇到一个union里面放一些非基本类型编译不通过的问题,查了一下得到如下解释
Current C++ standard does not allow non-POD types inside unions. Hence you get this compiler error from gcc.
Instead of using C unions, you should use boost::variant
. Check the doccumentationhere.
To add to the above:
The new C++ standard(C++0x) adds a new feature called as Unrestricted Unions, which supports storing non-POD types to a Union.