联合的编译错误 [英] Compilation error for union
本文介绍了联合的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以有人请解释为什么下面的程序导致编译问题。我已经编译VS2013的源代码。
can somebody please explain why the following program causing the compilation problem. I have compiled the source code over VS2013.
#include <iostream>
using namespace std;
// Do not work
union myuni
{
string str;
};
void main()
{
}
union声明时,union是否需要固定长度的大小?
Does union require the fixed length size while declaring it? The same scenario works fine with structure.
推荐答案
您不能有字符串
(尽管在C ++ 11中允许使用此方法,但不是在VS2013中支持)。
(Although allowed in C++11 this is not supported in VS2013).
这篇关于联合的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文