I have problem with initializating members of structures inside union. Union is a class member. I would like to initialize int members a 0 value. I found some similar solutions, but they didn't help me to solve my problem. I mean solution like initialization list or other, not m_union.structure1.value_s1 = 0
I suppose I need to create constructors inside structures? How should it look? Could I initialize all members inside union's body? To not do that in class constructor after creating a class member?
typedef union U1
{
struct S1
{
int value_s1;
}structure1;
struct S2
{
int value_s2;
int number_s2;
}structure2;
struct S3
{
int value_s3;
int number_s3;
}structure3;
}UNION_TYPE;
class Test_Class
{
public:
Test_Class();
UNION_TYPE m_union;
};
Test_Class::Test_Class()
{
}