If I have a class like this:
typedef union { __m128 quad; float numbers[4]; } Data
class foo
{
public:
foo() : m_Data() {}
Data m_Data;
};
and a class like this:
class bar
{
public:
bar() : m_Data() {}
foo m_Data;
}
is foo's constructor called when making an instance of bar?
Because when I try to use bar
's m_Data
's quad
in bar
it seems to be uninitialized, even though it has values in numbers[4]
. :\\
Specifically, this crashes:
m_Data.quad = _mm_mul_ps(m_Data.quad, a_Other.m_Data.quad)
Any help would be appreciated. :)
您必须将构造函数声明为public
,否则,如果您将类声明为private
成员,则不允许任何人实例化您的类。
Looks good for me. foo and bar are non-POD types because they have a constructor, so their members are guaranteed to be initialized after constructing.
Maybe the data is overwritten later through a memory leak?
How do you create the instance of bar?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.