考虑下面的代码:结构类型转换
struct A_struct
{
int x;
};
struct B_struct
{
int y;
};
int test(A_struct some_struct)
{
return some_struct.x;
}
B_struct B;
有人能解释这是什么样的类型转换的?
test((A_struct&)B);
这是实质上等同于:
test(*(A_struct*)&B);
我主要好奇他们是如何是等价的,因为我有麻烦发现,填补缺口的任何文本。
这是'无效'类型的演员,我相信,虽然我可能是错的。 – Mehrdad 2011-02-16 07:53:45