C++联合数组和变量? [英] C++ union array and vars?
本文介绍了C++联合数组和变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
没有办法做这样的事情,在 C++ 中有吗?
There's no way to do something like this, in C++ is there?
union {
{
Scalar x, y;
}
Scalar v[2];
};
x == v[0]
和 y == v[1]
在哪里?
推荐答案
怎么样
union {
struct {
int x;
int y;
};
int v[2];
};
union a {
struct b { int first, second; } bee;
int v[2];
};
丑陋,但更准确
这篇关于C++联合数组和变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文